<!DOCTYPE html><html lang="en"><head>
  <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  <meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name="viewport">
  <meta content="CR" name="w3c-status">
  <title>HTML 5.1: 6. Loading Web pages</title>
  <link href="styles/styles-html.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href=styles.default.css>
  <meta content="Bikeshed 1.0.0" name="generator">

  <link href="styles/W3C-CR" rel="stylesheet" type="text/css">
 </head>
 <body class="h-entry">
  <div class="head">
   <header>
    <p data-fill-with="logo"><a href="http://www.w3.org/"><img alt="W3C" height="48" src="styles/logos/W3C" width="72"></a></p>
    <h1 class="p-name no-ref allcaps" id="title">HTML 5.1</h1>
    <h2 class="no-num no-toc no-ref heading settled" id="subtitle"><span class="content">W3C Candidate Recommendation, <time class="dt-updated" datetime="2016-06-21">21 June 2016</time></span></h2>
   </header>
   
   
   
   
  </div>
  
  
  
  
  
  <nav data-fill-with="table-of-contents" id="toc"><p class="prev_next">← <a href="editing.html#editing"><span class="secno">5</span> <span class="content">User interaction</span></a> — <a href="index.html#contents">Table of contents</a> — <a href="webappapis.html#webappapis"><span class="secno">7</span> <span class="content">Web application APIs</span></a> →</p>
   <h2 class="no-num no-toc no-ref" id="contents">Table of Contents</h2>
   <ol class="toc" role="directory"><li>
     <a href="browsers.html#browsers"><span class="secno">6</span> <span class="content">Loading Web pages</span></a>
     <ol class="toc">
      <li>
       <a href="browsers.html#sec-browsing-contexts"><span class="secno">6.1</span> <span class="content">Browsing contexts</span></a>
       <ol class="toc">
        <li>
         <a href="browsers.html#sec-nested-browsing-contexts"><span class="secno">6.1.1</span> <span class="content"><span>Nested browsing contexts</span></span></a>
         <ol class="toc">
          <li><a href="browsers.html#navigating-nested-browsing-contexts-in-the-dom"><span class="secno">6.1.1.1</span> <span class="content">Navigating nested browsing contexts in the DOM</span></a>
         </li></ol>
        </li><li>
         <a href="browsers.html#sec-auxiliary-browsing-contexts"><span class="secno">6.1.2</span> <span class="content"><span>Auxiliary browsing contexts</span></span></a>
         <ol class="toc">
          <li><a href="browsers.html#navigating-auxiliary-browsing-contexts-in-the-dom"><span class="secno">6.1.2.1</span> <span class="content">Navigating auxiliary browsing contexts in the DOM</span></a>
         </li></ol>
        </li><li><a href="browsers.html#browsing-context-security"><span class="secno">6.1.3</span> <span class="content">Security</span></a>
        </li><li><a href="browsers.html#groupings-of-browsing-contexts"><span class="secno">6.1.4</span> <span class="content">Groupings of browsing contexts</span></a>
        </li><li><a href="browsers.html#browsing-context-names"><span class="secno">6.1.5</span> <span class="content">Browsing context names</span></a>
        </li><li><a href="browsers.html#script-settings-for-browsing-contexts"><span class="secno">6.1.6</span> <span class="content">Script settings for browsing contexts</span></a>
       </li></ol>
      </li><li>
       <a href="browsers.html#security-infrastructure-for-window-windowproxy-location"><span class="secno">6.2</span> <span class="content">Security infrastructure for <code>Window</code>, <code>WindowProxy</code>, and <code class="idl"><span>Location</span></code> objects</span></a>
       <ol class="toc">
        <li><a href="browsers.html#integration-with-idl"><span class="secno">6.2.1</span> <span class="content">Integration with IDL</span></a>
        </li><li><a href="browsers.html#shared-internal-slot-crossoriginpropertydescriptormap"><span class="secno">6.2.2</span> <span class="content">Shared internal slot: [[CrossOriginPropertyDescriptorMap]]</span></a>
        </li><li>
         <a href="browsers.html#shared-abstract-operations"><span class="secno">6.2.3</span> <span class="content">Shared abstract operations</span></a>
         <ol class="toc">
          <li><a href="browsers.html#crossoriginproperties-algorithm"><span class="secno">6.2.3.1</span> <span class="content"><span>CrossOriginProperties</span> ( <var>O</var> )</span></a>
          </li><li><a href="browsers.html#isplatformobjectsameorigin-algorithm"><span class="secno">6.2.3.2</span> <span class="content"><span>IsPlatformObjectSameOrigin</span> ( <var>O</var> )</span></a>
          </li><li>
           <a href="browsers.html#crossorigingetownpropertyhelper-algorithm"><span class="secno">6.2.3.3</span> <span class="content"><span>CrossOriginGetOwnPropertyHelper</span> ( <var>O</var>, <var>P</var> )</span></a>
           <ol class="toc">
            <li><a href="browsers.html#crossoriginpropertydescriptor-algorithm"><span class="secno">6.2.3.3.1</span> <span class="content"><span>CrossOriginPropertyDescriptor</span> ( <var>crossOriginProperty</var>, <var>originalDesc</var> )</span></a>
            </li><li><a href="browsers.html#crossoriginfunctionwrapper-algorithm"><span class="secno">6.2.3.3.2</span> <span class="content"><span>CrossOriginFunctionWrapper</span> ( <var>needsWrapping</var>, <var>functionToWrap</var> )</span></a>
           </li></ol>
          </li><li><a href="browsers.html#crossoriginget-algorithm"><span class="secno">6.2.3.4</span> <span class="content"><span>CrossOriginGet</span> ( <var>O</var>, <var>P</var>, <var>Receiver</var> )</span></a>
          </li><li><a href="browsers.html#crossoriginset-algorithm"><span class="secno">6.2.3.5</span> <span class="content"><span>CrossOriginSet</span> ( <var>O</var>, <var>P</var>, V, <var>Receiver</var> )</span></a>
          </li><li><a href="browsers.html#crossoriginownpropertykeys-algorithm"><span class="secno">6.2.3.6</span> <span class="content"><span>CrossOriginOwnPropertyKeys</span> ( <var>O</var> )</span></a>
         </li></ol>
       </li></ol>
      </li><li>
       <a href="browsers.html#the-window-object"><span class="secno">6.3</span> <span class="content">The <code>Window</code> object</span></a>
       <ol class="toc">
        <li><a href="browsers.html#apis-for-creating-and-navigating-browsing-contexts-by-name"><span class="secno">6.3.1</span> <span class="content">APIs for creating and navigating browsing contexts by name</span></a>
        </li><li><a href="browsers.html#accessing-other-browsing-contexts"><span class="secno">6.3.2</span> <span class="content">Accessing other browsing contexts</span></a>
        </li><li><a href="browsers.html#named-access-on-the-window-object"><span class="secno">6.3.3</span> <span class="content">Named access on the <code>Window</code> object</span></a>
        </li><li><a href="browsers.html#garbage-collection-and-browsing-contexts"><span class="secno">6.3.4</span> <span class="content">Garbage collection and browsing contexts</span></a>
        </li><li><a href="browsers.html#closing-browsing-contexts"><span class="secno">6.3.5</span> <span class="content">Closing browsing contexts</span></a>
        </li><li><a href="browsers.html#browser-interface-elements"><span class="secno">6.3.6</span> <span class="content">Browser interface elements</span></a>
        </li><li>
         <a href="browsers.html#the-windowproxy-object"><span class="secno">6.3.7</span> <span class="content">The <code>WindowProxy</code> object</span></a>
         <ol class="toc">
          <li>
           <a href="browsers.html#windowproxy-internal-methods"><span class="secno">6.3.7.1</span> <span class="content">The <code>WindowProxy</code> internal methods</span></a>
           <ol class="toc">
            <li><a href="browsers.html#windowproxy-getprototypeof-algorithm"><span class="secno">6.3.7.1.1</span> <span class="content">[[<span>GetPrototypeOf</span>]] ( )</span></a>
            </li><li><a href="browsers.html#windowproxy-setprototypeof-algorithm"><span class="secno">6.3.7.1.2</span> <span class="content">[[<span>SetPrototypeOf</span>]] ( V )</span></a>
            </li><li><a href="browsers.html#windowproxy-isextensible-algorithm"><span class="secno">6.3.7.1.3</span> <span class="content">[[<span>IsExtensible</span>]] ( )</span></a>
            </li><li><a href="browsers.html#windowproxy-preventextensions-algorithm"><span class="secno">6.3.7.1.4</span> <span class="content">[[<span>PreventExtensions</span>]] ( )</span></a>
            </li><li><a href="browsers.html#windowproxy-getownproperty-algorithm"><span class="secno">6.3.7.1.5</span> <span class="content">[[<span>GetOwnProperty</span>]] ( <var>P</var> )</span></a>
            </li><li><a href="browsers.html#windowproxy-defineownproperty-algorithm"><span class="secno">6.3.7.1.6</span> <span class="content">[[<span>DefineOwnProperty</span>]] ( <var>P</var>, <var>Desc</var> )</span></a>
            </li><li><a href="browsers.html#windowproxy-get-algorithm"><span class="secno">6.3.7.1.7</span> <span class="content">[[<span>Get</span>]] ( <var>P</var>, <var>Receiver</var> )</span></a>
            </li><li><a href="browsers.html#windowproxy-set-algorithm"><span class="secno">6.3.7.1.8</span> <span class="content">[[<span>Set</span>]] ( <var>P</var>, V, <var>Receiver</var> )</span></a>
            </li><li><a href="browsers.html#windowproxy-delete-algorithm"><span class="secno">6.3.7.1.9</span> <span class="content">[[<span>Delete</span>]] ( <var>P</var> )</span></a>
            </li><li><a href="browsers.html#windowproxy-ownpropertykeys-algorithm"><span class="secno">6.3.7.1.10</span> <span class="content">[[<span>OwnPropertyKeys</span>]] ( )</span></a>
           </li></ol>
         </li></ol>
       </li></ol>
      </li><li>
       <a href="browsers.html#section-origin"><span class="secno">6.4</span> <span class="content">Origin</span></a>
       <ol class="toc">
        <li><a href="browsers.html#relaxing-the-same-origin-restriction"><span class="secno">6.4.1</span> <span class="content">Relaxing the same-origin restriction</span></a>
       </li></ol>
      </li><li><a href="browsers.html#sandboxing"><span class="secno">6.5</span> <span class="content">Sandboxing</span></a>
      </li><li>
       <a href="browsers.html#session-history-and-navigation"><span class="secno">6.6</span> <span class="content">Session history and navigation</span></a>
       <ol class="toc">
        <li><a href="browsers.html#the-session-history-of-browsing-contexts"><span class="secno">6.6.1</span> <span class="content">The session history of browsing contexts</span></a>
        </li><li><a href="browsers.html#the-history-interface"><span class="secno">6.6.2</span> <span class="content">The <code>History</code> interface</span></a>
        </li><li><a href="browsers.html#sec-implementation-notes-for-session-history"><span class="secno">6.6.3</span> <span class="content"><span>Implementation notes for session history</span></span></a>
        </li><li><a href="browsers.html#the-location-interface"><span class="secno">6.6.4</span> <span class="content">The <code>Location</code> interface</span></a>
       </li></ol>
      </li><li>
       <a href="browsers.html#browsing-the-web"><span class="secno">6.7</span> <span class="content">Browsing the Web</span></a>
       <ol class="toc">
        <li><a href="browsers.html#navigating-across-documents"><span class="secno">6.7.1</span> <span class="content">Navigating across documents</span></a>
        </li><li><a href="browsers.html#page-load-processing-model-for-html-files"><span class="secno">6.7.2</span> <span class="content">Page load processing model for HTML files</span></a>
        </li><li><a href="browsers.html#page-load-processing-model-for-xml-files"><span class="secno">6.7.3</span> <span class="content">Page load processing model for XML files</span></a>
        </li><li><a href="browsers.html#page-load-processing-model-for-text-files"><span class="secno">6.7.4</span> <span class="content"><span>Page load processing model for text files</span></span></a>
        </li><li><a href="browsers.html#page-load-processing-model-for-multipartx-mixed-replace-resources"><span class="secno">6.7.5</span> <span class="content">Page load processing model for <code>multipart/x-mixed-replace</code> resources</span></a>
        </li><li><a href="browsers.html#page-load-processing-model-for-media"><span class="secno">6.7.6</span> <span class="content">Page load processing model for media</span></a>
        </li><li><a href="browsers.html#page-load-processing-model-for-content-that-uses-plugins"><span class="secno">6.7.7</span> <span class="content">Page load processing model for content that uses plugins</span></a>
        </li><li><a href="browsers.html#page-load-processing-model-for-inline-content-that-doesnt-have-a-dom"><span class="secno">6.7.8</span> <span class="content"><span>Page load processing model for inline content that doesn’t have a DOM</span></span></a>
        </li><li><a href="browsers.html#navigating-to-a-fragment-identifier"><span class="secno">6.7.9</span> <span class="content">Navigating to a <span>fragment identifier</span></span></a>
        </li><li>
         <a href="browsers.html#history-traversal"><span class="secno">6.7.10</span> <span class="content">History traversal</span></a>
         <ol class="toc">
          <li><a href="browsers.html#persisted-user-state-restoration"><span class="secno">6.7.10.1</span> <span class="content">Persisted user state restoration</span></a>
          </li><li><a href="browsers.html#the-popstateevent-interface"><span class="secno">6.7.10.2</span> <span class="content">The <code>PopStateEvent</code> interface</span></a>
          </li><li><a href="browsers.html#the-hashchangeevent-interface"><span class="secno">6.7.10.3</span> <span class="content">The <code>HashChangeEvent</code> interface</span></a>
          </li><li><a href="browsers.html#the-pagetransitionevent-interface"><span class="secno">6.7.10.4</span> <span class="content">The <code>PageTransitionEvent</code> interface</span></a>
         </li></ol>
        </li><li>
         <a href="browsers.html#unloading-documents"><span class="secno">6.7.11</span> <span class="content">Unloading documents</span></a>
         <ol class="toc">
          <li><a href="browsers.html#the-beforeunloadevent-interface"><span class="secno">6.7.11.1</span> <span class="content">The <code>BeforeUnloadEvent</code> interface</span></a>
         </li></ol>
        </li><li><a href="browsers.html#aborting-a-document-load"><span class="secno">6.7.12</span> <span class="content">Aborting a document load</span></a>
        </li><li><a href="browsers.html#browser-state"><span class="secno">6.7.13</span> <span class="content">Browser state</span></a>
       </li></ol>
     </li></ol>
    </li></ol>
  </nav><main><section>
    <h2 class="heading settled" data-level="6" id="browsers"><span class="secno">6. </span><span class="content">Loading Web pages</span><a class="self-link" href="browsers.html#browsers"></a></h2>
    <p>This section describes features that apply most directly to Web browsers. Having said that,
  except where specified otherwise, the requirements defined in this section <em>do</em> apply to
  all user agents, whether they are Web browsers or not.</p>
    <h3 class="heading settled" data-level="6.1" id="sec-browsing-contexts"><span class="secno">6.1. </span><span class="content">Browsing contexts</span><a class="self-link" href="browsers.html#sec-browsing-contexts"></a></h3>
    <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="browsing context|browsing contexts" data-noexport="" id="browsing-context">browsing context</dfn> is an environment in which <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> objects are presented to the user.</p>
    <p class="note" role="note">A tab or window in a Web browser typically contains a <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-93">browsing context</a>, as
  does an <code><a data-link-type="element" href="semantics-embedded-content.html#elementdef-iframe" id="ref-for-elementdef-iframe-55">iframe</a></code> or <code><a data-link-type="element" href="obsolete.html#elementdef-frame" id="ref-for-elementdef-frame-2">frame</a></code>s in a <code><a data-link-type="element" href="obsolete.html#elementdef-frameset" id="ref-for-elementdef-frameset-6">frameset</a></code>.</p>
    <p>A <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-94">browsing context</a> has a corresponding <code class="idl"><a data-link-type="idl" href="browsers.html#windowproxy" id="ref-for-windowproxy-5">WindowProxy</a></code> object.</p>
    <p>A <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-95">browsing context</a> has a <a data-link-type="dfn" href="browsers.html#session-history" id="ref-for-session-history-2">session history</a>, which lists the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> objects that the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-96">browsing context</a> has presented, is
  presenting, or will present. At any time, one <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> in each <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-97">browsing context</a> is designated the <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="active-document">active document</dfn>. A <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-98">browsing context</a> is that <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-99">browsing context</a> whose <a data-link-type="dfn" href="browsers.html#session-history" id="ref-for-session-history-3">session
  history</a> contains the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>, if any. (A <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> created using
  an API such as <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#dom-domimplementation-createdocument">createDocument()</a></code> has no <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-100">browsing context</a>.) Each <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> in a <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-101">browsing context</a> is <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="document associated with a window" data-noexport="" id="document-associated-with-a-window">associated</dfn> with
  a <code class="idl"><a data-link-type="idl" href="browsers.html#window-window" id="ref-for-window-window-9">Window</a></code> object.</p>
    <p class="note" role="note"> In general, there is a 1-to-1 mapping from the <code class="idl"><a data-link-type="idl" href="browsers.html#window-window" id="ref-for-window-window-10">Window</a></code> object to the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object. There are two exceptions. First, a <code class="idl"><a data-link-type="idl" href="browsers.html#window-window" id="ref-for-window-window-11">Window</a></code> can be reused
  for the presentation of a second <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> in the same <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-102">browsing context</a>,
  such that the mapping is then 1-to-2. This occurs when a <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-103">browsing context</a> is <a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-35">navigated</a> from the initial <code>about:blank</code> <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> to another, with <a data-link-type="dfn" href="browsers.html#replacement-must-be-enabled" id="ref-for-replacement-must-be-enabled-9">replacement enabled</a>. Second, a <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> can end up
  being reused for several <code class="idl"><a data-link-type="idl" href="browsers.html#window-window" id="ref-for-window-window-12">Window</a></code> objects when the <code class="idl"><a data-link-type="idl" href="webappapis.html#dom-document-_open" id="ref-for-dom-document-_open-3">document.open()</a></code> method is
  used, such that the mapping is then many-to-1.</p>
    <p class="note" role="note">A <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> does not necessarily have a <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-104">browsing context</a> associated with it. In particular, data mining tools are likely to never instantiate browsing
  contexts.</p>
    <hr>
    <p>A <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-105">browsing context</a> can have a <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="creator-browsing-context">creator browsing context</dfn>, the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-106">browsing context</a> that was responsible for its creation. If a <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-107">browsing context</a> has a <a data-link-type="dfn" href="browsers.html#parent-browsing-context" id="ref-for-parent-browsing-context-5">parent browsing context</a>, then that is its <a data-link-type="dfn" href="browsers.html#creator-browsing-context" id="ref-for-creator-browsing-context-2">creator browsing context</a>. Otherwise, if
  the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-108">browsing context</a> has an <a data-link-type="dfn" href="browsers.html#opener-browsing-context" id="ref-for-opener-browsing-context-1">opener browsing context</a>, then <em>that</em> is its <a data-link-type="dfn" href="browsers.html#creator-browsing-context" id="ref-for-creator-browsing-context-3">creator browsing context</a>. Otherwise, the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-109">browsing context</a> has no <a data-link-type="dfn" href="browsers.html#creator-browsing-context" id="ref-for-creator-browsing-context-4">creator browsing context</a>.</p>
    <p>If a <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-110">browsing context</a> <var>A</var> has a <a data-link-type="dfn" href="browsers.html#creator-browsing-context" id="ref-for-creator-browsing-context-5">creator browsing context</a>, then the <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="creator-origin">creator origin</dfn>, <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="creator-url">creator URL</dfn>, and <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="creator-base-url">creator base URL</dfn> are the <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-27">origin</a>, <a data-link-type="dfn" href="https://www.w3.org/TR/dom/#concept-document-url">URL</a>, and <a data-link-type="dfn" href="infrastructure.html#document-base-url" id="ref-for-document-base-url-11">base URL</a>, respectively, of
  the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> that was the <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-38">active document</a> of that <a data-link-type="dfn" href="browsers.html#creator-browsing-context" id="ref-for-creator-browsing-context-6">creator browsing context</a> at
  the time <var>A</var> was created.</p>
    <p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="creating a new browsing context|create a new browsing context" data-noexport="" id="creating-a-new-browsing-context">create a new browsing context</dfn>:</p>
    <ol>
     <li data-md="">
      <p>Call the JavaScript <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-initializehostdefinedrealm">InitializeHostDefinedRealm</a>() abstract operation with the following
  customizations:</p>
      <ul>
       <li data-md="">
        <p>For the global object, create a new <code class="idl"><a data-link-type="idl" href="browsers.html#window-window" id="ref-for-window-window-13">Window</a></code> object <var>window</var>.</p>
       </li><li data-md="">
        <p>For the global <em>this</em> value, create a new <code class="idl"><a data-link-type="idl" href="browsers.html#windowproxy" id="ref-for-windowproxy-6">WindowProxy</a></code> object <var>windowProxy</var>, whose [[<code class="idl"><a data-link-type="idl" href="browsers.html#window-window" id="ref-for-window-window-14">Window</a></code>]] internal slot value is <var>window</var>.</p>
        <p class="note" role="note">The internal slot value is updated when navigations occur.</p>
       </li><li data-md="">
        <p>Let <var>realm execution context</var> be the created <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-execution-contexts">JavaScript execution context</a>.</p>
      </li></ul>
     </li><li data-md="">
      <p>Set the new <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-111">browsing context</a>’s associated <code class="idl"><a data-link-type="idl" href="browsers.html#windowproxy" id="ref-for-windowproxy-7">WindowProxy</a></code> to <var>windowProxy</var>.</p>
     </li><li data-md="">
      <p>Let <var>document</var> be a new <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>, whose <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a> is <a data-link-type="scheme" href="infrastructure.html#schemedef-about" id="ref-for-schemedef-about-5">about:blank</a>, which is marked as being an <a data-link-type="dfn" href="infrastructure.html#html-document" id="ref-for-html-document-25">HTML document</a>, whose <a data-link-type="dfn" href="infrastructure.html#character-encoding" id="ref-for-character-encoding-16">character encoding</a> is UTF-8, and which is both <a data-link-type="dfn" href="syntax.html#ready-for-post-load-tasks" id="ref-for-ready-for-post-load-tasks-5">ready for post-load tasks</a> and <a data-link-type="dfn" href="syntax.html#completely-loaded" id="ref-for-completely-loaded-6">completely loaded</a> immediately.</p>
     </li><li data-md="">
      <p>Set the <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-28">origin</a> of <var>document</var>:</p>
      <ul>
       <li data-md="">
        <p>If the new <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-112">browsing context</a> has a <a data-link-type="dfn" href="browsers.html#creator-browsing-context" id="ref-for-creator-browsing-context-7">creator browsing context</a>, then the <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-29">origin</a> of <var>document</var> is the <a data-link-type="dfn" href="browsers.html#creator-origin" id="ref-for-creator-origin-1">creator origin</a>.</p>
       </li><li data-md="">
        <p>Otherwise, the <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-30">origin</a> of <var>document</var> is a unique <a data-link-type="dfn" href="browsers.html#opaque-origin" id="ref-for-opaque-origin-3">opaque origin</a> assigned when the new <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-113">browsing context</a> is created.</p>
      </li></ul>
     </li><li data-md="">
      <p>If the new <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-114">browsing context</a> has a <a data-link-type="dfn" href="browsers.html#creator-browsing-context" id="ref-for-creator-browsing-context-8">creator browsing context</a>, then set <var>document</var>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-referrer">referrer</a> to the <a data-link-type="dfn" href="browsers.html#creator-url" id="ref-for-creator-url-1">creator URL</a>.</p>
     </li><li data-md="">
      <p>Ensure that <var>document</var> has a single child <code><a data-link-type="element" href="semantics.html#elementdef-html" id="ref-for-elementdef-html-26">html</a></code> node, which itself has two empty
  child nodes: a <code><a data-link-type="element" href="document-metadata.html#elementdef-head" id="ref-for-elementdef-head-41">head</a></code> element, and a <code><a data-link-type="element" href="sections.html#elementdef-body" id="ref-for-elementdef-body-57">body</a></code> element.</p>
     </li><li data-md="">
      <p><a data-link-type="dfn" href="browsers.html#implement-the-sandboxing" id="ref-for-implement-the-sandboxing-1">Implement the sandboxing</a> for <var>document</var>.</p>
     </li><li data-md="">
      <p>Add <var>document</var> to the new <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-115">browsing context</a>’s <a data-link-type="dfn" href="browsers.html#session-history" id="ref-for-session-history-4">session history</a>.</p>
     </li><li data-md="">
      <p>Set <var>window</var>’s associated <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> to <var>document</var>.</p>
     </li><li data-md="">
      <p><a data-link-type="dfn" href="browsers.html#set-up-a-browsing-context-environment-settings-object" id="ref-for-set-up-a-browsing-context-environment-settings-object-1">Set up a browsing context environment settings object</a> with <var>realm execution context</var>.</p>
    </li></ol>
    <h4 class="heading settled" data-level="6.1.1" id="sec-nested-browsing-contexts"><span class="secno">6.1.1. </span><span class="content"><dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="nested browsing contexts|nested browsing context" data-noexport="" id="nested-browsing-contexts">Nested browsing contexts</dfn></span><a class="self-link" href="browsers.html#sec-nested-browsing-contexts"></a></h4>
    <p>Certain elements (for example, <code><a data-link-type="element" href="semantics-embedded-content.html#elementdef-iframe" id="ref-for-elementdef-iframe-56">iframe</a></code> elements) can instantiate further <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-116">browsing contexts</a>. These are called nested browsing contexts. If a browsing context <var>P</var> has a <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> <var>D</var> with an element <var>E</var> that nests
  another browsing context <var>C</var> inside it, then <var>C</var> is said to be <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="through which new document is nested|nested through" data-noexport="" id="through-which-new-document-is-nested">nested through</dfn> <var>D</var>, and <var>E</var> is said to be the <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="browsing-context-container">browsing context container</dfn> of <var>C</var>.
  If the <a data-link-type="dfn" href="browsers.html#browsing-context-container" id="ref-for-browsing-context-container-23">browsing context container</a> element <var>E</var> is <a data-link-type="dfn" href="infrastructure.html#in-the-document" id="ref-for-in-the-document-24">in the <code>Document</code></a> <var>D</var>, then <var>P</var> is
  said to be the <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="parent-browsing-context">parent browsing context</dfn> of <var>C</var> and <var>C</var> is said to be a <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="child browsing context|child browsing contexts" data-noexport="" id="child-browsing-context">child browsing context</dfn> of <var>P</var>.
  Otherwise, the <a data-link-type="dfn" href="browsers.html#nested-browsing-contexts" id="ref-for-nested-browsing-contexts-54">nested browsing context</a> <var>C</var> has no <a data-link-type="dfn" href="browsers.html#parent-browsing-context" id="ref-for-parent-browsing-context-6">parent
  browsing context</a>.</p>
    <p>A browsing context <var>A</var> is said to be an <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="ancestor browsing context|ancestor" data-noexport="" id="ancestor-browsing-context">ancestor</dfn> of a browsing context <var>B</var> if there exists a browsing
  context <var>A</var> that is a <a data-link-type="dfn" href="browsers.html#child-browsing-context" id="ref-for-child-browsing-context-8">child browsing context</a> of <var>A</var> and that is itself an <a data-link-type="dfn" href="browsers.html#ancestor-browsing-context" id="ref-for-ancestor-browsing-context-2">ancestor</a> of <var>B</var>, or if the browsing context <var>A</var> is the <a data-link-type="dfn" href="browsers.html#parent-browsing-context" id="ref-for-parent-browsing-context-7">parent browsing context</a> of <var>B</var>.</p>
    <p>A browsing context that is not a <a data-link-type="dfn" href="browsers.html#nested-browsing-contexts" id="ref-for-nested-browsing-contexts-55">nested browsing context</a> has no <a data-link-type="dfn" href="browsers.html#parent-browsing-context" id="ref-for-parent-browsing-context-8">parent
  browsing context</a>, and is the <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="top-level-browsing-context">top-level browsing context</dfn> of all the browsing
  contexts for which it is an <a data-link-type="dfn" href="browsers.html#ancestor-browsing-context" id="ref-for-ancestor-browsing-context-3">ancestor browsing context</a>.</p>
    <p>The transitive closure of <a data-link-type="dfn" href="browsers.html#parent-browsing-context" id="ref-for-parent-browsing-context-9">parent browsing contexts</a> for a <a data-link-type="dfn" href="browsers.html#nested-browsing-contexts" id="ref-for-nested-browsing-contexts-56">nested browsing context</a> gives the list of <a data-link-type="dfn" href="browsers.html#ancestor-browsing-context" id="ref-for-ancestor-browsing-context-4">ancestor browsing contexts</a>.</p>
    <p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="list-of-the-descendant-browsing-contexts">list of the descendant browsing contexts</dfn> of a <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> <var>d</var> is the (ordered) list returned by the following algorithm:</p>
    <ol>
     <li>Let <var>list</var> be an empty list.
     </li><li>
      <p>For each <a data-link-type="dfn" href="browsers.html#child-browsing-context" id="ref-for-child-browsing-context-9">child browsing context</a> of <var>d</var> that is <a data-link-type="dfn" href="browsers.html#through-which-new-document-is-nested" id="ref-for-through-which-new-document-is-nested-1">nested through</a> an element that is <a data-link-type="dfn" href="infrastructure.html#in-the-document" id="ref-for-in-the-document-25">in the <code>Document</code></a> <var>d</var>, in the <a data-link-type="dfn" href="infrastructure.html#tree-order" id="ref-for-tree-order-73">tree
    order</a> of the elements nesting those <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-117">browsing
    contexts</a>, run these substeps:</p>
      <ol>
       <li>Append that <a data-link-type="dfn" href="browsers.html#child-browsing-context" id="ref-for-child-browsing-context-10">child browsing context</a> to the list <var>list</var>. 
       </li><li>Append the <a data-link-type="dfn" href="browsers.html#list-of-the-descendant-browsing-contexts" id="ref-for-list-of-the-descendant-browsing-contexts-1">list of the descendant browsing contexts</a> of the <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-39">active
      document</a> of that <a data-link-type="dfn" href="browsers.html#child-browsing-context" id="ref-for-child-browsing-context-11">child browsing context</a> to the list <var>list</var>.
      </li></ol>
     </li><li>Return the constructed <var>list</var>.
    </li></ol>
    <p>A <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> is said to be <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="fully-active">fully active</dfn> when it has a <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-118">browsing context</a> and it is the <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-40">active document</a> of
  that <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-119">browsing context</a>, and either its browsing context is a <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-21">top-level browsing context</a>, or it has a <a data-link-type="dfn" href="browsers.html#parent-browsing-context" id="ref-for-parent-browsing-context-10">parent browsing context</a> and the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> through which it is nested is itself <a data-link-type="dfn" href="browsers.html#fully-active" id="ref-for-fully-active-17">fully active</a>.</p>
    <p>Because they are nested through an element, <a data-link-type="dfn" href="browsers.html#child-browsing-context" id="ref-for-child-browsing-context-12">child browsing contexts</a> are always tied to a
  specific <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> in their <a data-link-type="dfn" href="browsers.html#parent-browsing-context" id="ref-for-parent-browsing-context-11">parent browsing context</a>. User agents must not allow the user
  to interact with <a data-link-type="dfn" href="browsers.html#child-browsing-context" id="ref-for-child-browsing-context-13">child browsing contexts</a> of elements that are in <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>s that are
  not themselves <a data-link-type="dfn" href="browsers.html#fully-active" id="ref-for-fully-active-18">fully active</a>.</p>
    <p>A <a data-link-type="dfn" href="browsers.html#nested-browsing-contexts" id="ref-for-nested-browsing-contexts-57">nested browsing context</a> can be put into a <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="delaying-load-events-mode">delaying <code>load</code> events mode</dfn>. This is used when it is <a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-36">navigated</a>, to <a data-link-type="dfn" href="syntax.html#delay-the-load-event" id="ref-for-delay-the-load-event-30">delay the load event</a> of the <a data-link-type="dfn" href="browsers.html#browsing-context-container" id="ref-for-browsing-context-container-24">browsing
  context container</a> before the new <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> is created.</p>
    <p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="document-family">document family</dfn> of a <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-120">browsing context</a> consists of the union of all
  the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> objects in that <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-121">browsing context</a>’s <a data-link-type="dfn" href="browsers.html#session-history" id="ref-for-session-history-5">session
  history</a> and the <a data-link-type="dfn" href="browsers.html#document-family" id="ref-for-document-family-1">document families</a> of all those <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> objects. The <a data-link-type="dfn" href="browsers.html#document-family" id="ref-for-document-family-2">document family</a> of a <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object
  consists of the union of all the <a data-link-type="dfn" href="browsers.html#document-family" id="ref-for-document-family-3">document families</a> of the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-122">browsing contexts</a> that are <a data-link-type="dfn" href="browsers.html#through-which-new-document-is-nested" id="ref-for-through-which-new-document-is-nested-2">nested through</a> the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object.</p>
    <h5 class="heading settled" data-level="6.1.1.1" id="navigating-nested-browsing-contexts-in-the-dom"><span class="secno">6.1.1.1. </span><span class="content">Navigating nested browsing contexts in the DOM</span><a class="self-link" href="browsers.html#navigating-nested-browsing-contexts-in-the-dom"></a></h5>
    <dl class="domintro">
     <dt><var>window</var> . <code>top</code>
     </dt><dd>
      <p>Returns the <code>WindowProxy</code> for the <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-22">top-level browsing context</a>.</p>
     </dd><dt><var>window</var> . <code>parent</code>
     </dt><dd>
      <p>Returns the <code>WindowProxy</code> for the <a data-link-type="dfn" href="browsers.html#parent-browsing-context" id="ref-for-parent-browsing-context-12">parent browsing context</a>.</p>
     </dd><dt><var>window</var> . <code>frameElement</code>
     </dt><dd>
      <p>Returns the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#interface-element">Element</a></code> for the <a data-link-type="dfn" href="browsers.html#browsing-context-container" id="ref-for-browsing-context-container-25">browsing context container</a>.</p>
      <p>Returns null if there isn’t one, and in cross-origin situations.</p>
    </dd></dl>
    <p>The <dfn data-dfn-type="dfn" data-noexport="" id="top"><code>top</code><a class="self-link" href="browsers.html#top"></a></dfn> IDL attribute on the <code>Window</code> object
  of a <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> in a <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-123">browsing context</a> <var>b</var> must return
  the <code>WindowProxy</code> object of its <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-23">top-level browsing context</a> (which would be
  its own <code>WindowProxy</code> object if it was a <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-24">top-level browsing context</a> itself), if it has one, or its own <code>WindowProxy</code> object otherwise (e.g., if it was a
  detached <a data-link-type="dfn" href="browsers.html#nested-browsing-contexts" id="ref-for-nested-browsing-contexts-58">nested browsing context</a>).</p>
    <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="Window" data-dfn-type="attribute" data-export="" id="dom-window-parent"><code>parent</code></dfn> IDL attribute on the <code class="idl"><a data-link-type="idl" href="browsers.html#window-window" id="ref-for-window-window-15">Window</a></code> object
  of a <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> that has a <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-124">browsing context</a> <var>b</var> must return the <code class="idl"><a data-link-type="idl" href="browsers.html#windowproxy" id="ref-for-windowproxy-8">WindowProxy</a></code> object of the <a data-link-type="dfn" href="browsers.html#parent-browsing-context" id="ref-for-parent-browsing-context-13">parent browsing context</a>, if there is one (i.e., if <var>b</var> is a <a data-link-type="dfn" href="browsers.html#child-browsing-context" id="ref-for-child-browsing-context-14">child browsing context</a>), or the <code class="idl"><a data-link-type="idl" href="browsers.html#windowproxy" id="ref-for-windowproxy-9">WindowProxy</a></code> object of the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-125">browsing context</a> <var>b</var> itself, otherwise (i.e., if it is a <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-25">top-level browsing context</a> or a detached <a data-link-type="dfn" href="browsers.html#nested-browsing-contexts" id="ref-for-nested-browsing-contexts-59">nested browsing context</a>).</p>
    <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="Window" data-dfn-type="attribute" data-export="" id="dom-window-frameelement"><code>frameElement</code></dfn> IDL attribute, on getting, must
  run the following algorithm:</p>
    <ol>
     <li data-md="">
      <p>Let <var>d</var> be the <code class="idl"><a data-link-type="idl" href="browsers.html#window-window" id="ref-for-window-window-16">Window</a></code> object’s <a data-link-type="dfn" href="browsers.html#document-associated-with-a-window" id="ref-for-document-associated-with-a-window-1">associated <code>Document</code></a>.</p>
     </li><li data-md="">
      <p>Let <var>context</var> be <var>d</var>’s <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-126">browsing context</a>.</p>
     </li><li data-md="">
      <p>If <var>context</var> is not a <a data-link-type="dfn" href="browsers.html#nested-browsing-contexts" id="ref-for-nested-browsing-contexts-60">nested browsing context</a>, return null and abort these
  steps.</p>
     </li><li data-md="">
      <p>Let <var>container</var> be <var>context</var>’s <a data-link-type="dfn" href="browsers.html#browsing-context-container" id="ref-for-browsing-context-container-26">browsing context container</a>.</p>
     </li><li data-md="">
      <p>If <var>container</var>’s <a data-link-type="dfn" href="https://www.w3.org/TR/dom/#concept-node-document">node document</a>’s <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-31">origin</a> is not <a data-link-type="dfn" href="browsers.html#same-origin-domain" id="ref-for-same-origin-domain-3">same origin-domain</a> with the <a data-link-type="dfn" href="webappapis.html#entry-settings-object" id="ref-for-entry-settings-object-5">entry settings object</a>’s <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-32">origin</a>,
  then return null and abort these steps.</p>
     </li><li data-md="">
      <p>Return <var>container</var>.</p>
    </li></ol>
    <h4 class="heading settled" data-level="6.1.2" id="sec-auxiliary-browsing-contexts"><span class="secno">6.1.2. </span><span class="content"><dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="auxiliary browsing contexts|auxiliary browsing context" data-noexport="" id="auxiliary-browsing-contexts">Auxiliary browsing contexts</dfn></span><a class="self-link" href="browsers.html#sec-auxiliary-browsing-contexts"></a></h4>
    <p>It is possible to create new browsing contexts that are related to a <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-26">top-level browsing
  context</a> without being nested through an element. Such browsing contexts are called <a data-link-type="dfn" href="browsers.html#auxiliary-browsing-contexts" id="ref-for-auxiliary-browsing-contexts-1">auxiliary browsing contexts</a>. Auxiliary browsing contexts
  are always <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-27">top-level browsing contexts</a>.</p>
    <p>An <a data-link-type="dfn" href="browsers.html#auxiliary-browsing-contexts" id="ref-for-auxiliary-browsing-contexts-2">auxiliary browsing context</a> has an <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="opener-browsing-context">opener browsing context</dfn>, which is
  the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-127">browsing context</a> from which the <a data-link-type="dfn" href="browsers.html#auxiliary-browsing-contexts" id="ref-for-auxiliary-browsing-contexts-3">auxiliary browsing context</a> was
  created.</p>
    <h5 class="heading settled" data-level="6.1.2.1" id="navigating-auxiliary-browsing-contexts-in-the-dom"><span class="secno">6.1.2.1. </span><span class="content">Navigating auxiliary browsing contexts in the DOM</span><a class="self-link" href="browsers.html#navigating-auxiliary-browsing-contexts-in-the-dom"></a></h5>
    <p>The <dfn data-dfn-type="dfn" data-noexport="" id="opener"><code>opener</code><a class="self-link" href="browsers.html#opener"></a></dfn> IDL attribute on the <code>Window</code> object, on getting, must return the <code>WindowProxy</code> object of the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-128">browsing
  context</a> from which the current <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-129">browsing context</a> was created (its <a data-link-type="dfn" href="browsers.html#opener-browsing-context" id="ref-for-opener-browsing-context-2">opener
  browsing context</a>), if there is one, if it is still available, and if the current <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-130">browsing context</a> has not <i>disowned its opener</i>;
  otherwise, it must return null. On setting, if the new value is null then the current <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-131">browsing context</a> must <dfn data-dfn-type="dfn" data-noexport="" id="disown-its-opener">disown its opener<a class="self-link" href="browsers.html#disown-its-opener"></a></dfn>; if
  the new value is anything else then the user agent must
  call the [[DefineOwnProperty]] internal method of the <code>Window</code> object, passing the
  property name "<code>opener</code>" as the property key, and the Property Descriptor {
  [[Value]]: <var>value</var>, [[Writable]]: true, [[Enumerable]]: true,
  [[Configurable]]: true } as the property descriptor,
  where <var>value</var> is the new value.</p>
    <h4 class="heading settled" data-level="6.1.3" id="browsing-context-security"><span class="secno">6.1.3. </span><span class="content">Security</span><a class="self-link" href="browsers.html#browsing-context-security"></a></h4>
    <p>A <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-132">browsing context</a> <var>A</var> is <dfn data-dfn-type="dfn" data-lt="familiar with" data-noexport="" id="familiar-with">familiar
  with<a class="self-link" href="browsers.html#familiar-with"></a></dfn> a second <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-133">browsing context</a> <var>B</var> if one of the following
  conditions is true:</p>
    <ul>
     <li>Either the <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-33">origin</a> of the <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-41">active document</a> of <var>A</var> is the same as the <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-34">origin</a> of the <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-42">active
    document</a> of <var>B</var>, or
     </li><li>The browsing context <var>A</var> is a <a data-link-type="dfn" href="browsers.html#nested-browsing-contexts" id="ref-for-nested-browsing-contexts-61">nested browsing context</a> with a <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-28">top-level browsing context</a>, and its <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-29">top-level browsing context</a> is <var>B</var>, or
     </li><li>The browsing context <var>B</var> is an <a data-link-type="dfn" href="browsers.html#auxiliary-browsing-contexts" id="ref-for-auxiliary-browsing-contexts-4">auxiliary browsing context</a> and <var>A</var> is familiar with <var>B</var>’s <a data-link-type="dfn" href="browsers.html#opener-browsing-context" id="ref-for-opener-browsing-context-3">opener
    browsing context</a>, or
     </li><li>The browsing context <var>B</var> is not a <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-30">top-level browsing context</a>,
    but there exists an <a data-link-type="dfn" href="browsers.html#ancestor-browsing-context" id="ref-for-ancestor-browsing-context-5">ancestor browsing context</a> of <var>B</var> whose <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-43">active document</a> has the <a data-link-type="dfn" href="browsers.html#same-origin" id="ref-for-same-origin-13">same origin</a> as
    the <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-44">active document</a> of <var>A</var> (possibly in fact being <var>A</var> itself).
    </li></ul>
    <hr>
    <p>A <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-134">browsing context</a> <var>A</var> is <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="allowed-to-navigate">allowed to navigate</dfn> a
  second <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-135">browsing context</a> <var>B</var> if the following algorithm terminates
  positively:</p>
    <ol>
     <li>If <var>A</var> is not the same <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-136">browsing context</a> as <var>B</var>, and <var>A</var> is not one of the <a data-link-type="dfn" href="browsers.html#ancestor-browsing-context" id="ref-for-ancestor-browsing-context-6">ancestor browsing contexts</a> of <var>B</var>, and <var>B</var> is not a <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-31">top-level browsing context</a>, and <var>A</var>’s <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-45">active
    document</a>’s <a data-link-type="dfn" href="browsers.html#active-sandboxing-flag-set" id="ref-for-active-sandboxing-flag-set-7">active sandboxing flag set</a> has its <a data-link-type="dfn" href="browsers.html#sandboxed-navigation-browsing-context-flag" id="ref-for-sandboxed-navigation-browsing-context-flag-1">sandboxed navigation
    browsing context flag</a> set, then abort these steps negatively.
     </li><li>Otherwise, if <var>B</var> is a <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-32">top-level browsing context</a>, and is
    one of the <a data-link-type="dfn" href="browsers.html#ancestor-browsing-context" id="ref-for-ancestor-browsing-context-7">ancestor browsing contexts</a> of <var>A</var>, and <var>A</var>’s <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-46">active document</a>’s <a data-link-type="dfn" href="browsers.html#active-sandboxing-flag-set" id="ref-for-active-sandboxing-flag-set-8">active sandboxing
    flag set</a> has its <a data-link-type="dfn" href="browsers.html#sandboxed-top-level-navigation-browsing-context-flag" id="ref-for-sandboxed-top-level-navigation-browsing-context-flag-1">sandboxed top-level navigation browsing context flag</a> set,
    then abort these steps negatively.
     </li><li>Otherwise, if <var>B</var> is a <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-33">top-level browsing context</a>, and is
    neither <var>A</var> nor one of the <a data-link-type="dfn" href="browsers.html#ancestor-browsing-context" id="ref-for-ancestor-browsing-context-8">ancestor
    browsing contexts</a> of <var>A</var>, and <var>A</var>’s <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <a data-link-type="dfn" href="browsers.html#active-sandboxing-flag-set" id="ref-for-active-sandboxing-flag-set-9">active sandboxing flag set</a> has its <a data-link-type="dfn" href="browsers.html#sandboxed-navigation-browsing-context-flag" id="ref-for-sandboxed-navigation-browsing-context-flag-2">sandboxed
    navigation browsing context flag</a> set, and <var>A</var> is not the <a data-link-type="dfn" href="browsers.html#one-permitted-sandboxed-navigator" id="ref-for-one-permitted-sandboxed-navigator-2">one
    permitted sandboxed navigator</a> of <var>B</var>, then abort these steps
    negatively.
     </li><li>Otherwise, terminate positively!
    </li></ol>
    <hr>
    <p>An element has a <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="browsing-context-scope-origin">browsing context scope origin</dfn> if its <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-137">browsing context</a> is a <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-34">top-level browsing context</a> or if all of its <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <a data-link-type="dfn" href="browsers.html#ancestor-browsing-context" id="ref-for-ancestor-browsing-context-9">ancestor browsing contexts</a> all have <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-47">active documents</a> whose <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-35">origin</a> are the <a data-link-type="dfn" href="browsers.html#same-origin" id="ref-for-same-origin-14">same origin</a> as the element’s <a data-link-type="dfn" href="https://www.w3.org/TR/dom/#concept-node-document">node document</a>’s <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-36">origin</a>. If an
  element has a <a data-link-type="dfn" href="browsers.html#browsing-context-scope-origin" id="ref-for-browsing-context-scope-origin-3">browsing context scope origin</a>, then its value is the <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-37">origin</a> of the element’s <a data-link-type="dfn" href="https://www.w3.org/TR/dom/#concept-node-document">node document</a>.</p>
    <h4 class="heading settled" data-level="6.1.4" id="groupings-of-browsing-contexts"><span class="secno">6.1.4. </span><span class="content">Groupings of browsing contexts</span><a class="self-link" href="browsers.html#groupings-of-browsing-contexts"></a></h4>
    <p>Each <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-138">browsing context</a> is defined as having a list of one or more <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="directly-reachable-browsing-contexts">directly reachable browsing contexts</dfn>. These are:</p>
    <ul>
     <li data-md="">
      <p>The <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-139">browsing context</a> itself.</p>
     </li><li data-md="">
      <p>All the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-140">browsing context</a>’s <a data-link-type="dfn" href="browsers.html#child-browsing-context" id="ref-for-child-browsing-context-15">child browsing contexts</a>.</p>
     </li><li data-md="">
      <p>The <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-141">browsing context</a>’s <a data-link-type="dfn" href="browsers.html#parent-browsing-context" id="ref-for-parent-browsing-context-14">parent browsing context</a>.</p>
     </li><li data-md="">
      <p>All the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-142">browsing contexts</a> that have the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-143">browsing context</a> as their <a data-link-type="dfn" href="browsers.html#opener-browsing-context" id="ref-for-opener-browsing-context-4">opener browsing context</a>.</p>
     </li><li data-md="">
      <p>The <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-144">browsing context</a>’s <a data-link-type="dfn" href="browsers.html#opener-browsing-context" id="ref-for-opener-browsing-context-5">opener browsing context</a>.</p>
    </li></ul>
    <p>The transitive closure of all the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-145">browsing contexts</a> that are <a data-link-type="dfn" href="browsers.html#directly-reachable-browsing-contexts" id="ref-for-directly-reachable-browsing-contexts-1">directly reachable browsing contexts</a> forms a <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="unit-of-related-browsing-contexts">unit of related browsing contexts</dfn>.</p>
    <p>Each <a data-link-type="dfn" href="browsers.html#unit-of-related-browsing-contexts" id="ref-for-unit-of-related-browsing-contexts-1">unit of related browsing contexts</a> is then further divided into the smallest number of
  groups such that every member of each group has an <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-48">active document</a> with an <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-38">origin</a> that, through appropriate manipulation of the <code class="idl"><a data-link-type="idl" href="browsers.html#dom-document-domain" id="ref-for-dom-document-domain-2">document.domain</a></code> attribute, could be made to be <a data-link-type="dfn" href="browsers.html#same-origin-domain" id="ref-for-same-origin-domain-4">same origin-domain</a> with
  other members of the group, but could not be made the same as members of any other group. Each
  such group is a <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="units of related similar-origin browsing contexts|unit of related similar-origin browsing contexts" data-noexport="" id="units-of-related-similar-origin-browsing-contexts">unit of related similar-origin browsing contexts</dfn>.</p>
    <p class="note" role="note">There is also at most one <a data-link-type="dfn" href="webappapis.html#event-loop" id="ref-for-event-loop-27">event loop</a> per <a data-link-type="dfn" href="browsers.html#units-of-related-similar-origin-browsing-contexts" id="ref-for-units-of-related-similar-origin-browsing-contexts-1">unit of related similar-origin browsing contexts</a> (though several <a data-link-type="dfn" href="browsers.html#units-of-related-similar-origin-browsing-contexts" id="ref-for-units-of-related-similar-origin-browsing-contexts-2">units of related similar-origin browsing contexts</a> can have a shared <a data-link-type="dfn" href="webappapis.html#event-loop" id="ref-for-event-loop-28">event loop</a>).</p>
    <h4 class="heading settled" data-level="6.1.5" id="browsing-context-names"><span class="secno">6.1.5. </span><span class="content">Browsing context names</span><a class="self-link" href="browsers.html#browsing-context-names"></a></h4>
    <p>Browsing contexts can have a <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="browsing-context-name">browsing context name</dfn>. By default, a browsing context
  has no name (its name is not set).</p>
    <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="valid-browsing-context-name">valid browsing context name</dfn> is any string with at least one character that does
  not start with a U+005F LOW LINE character. (Names starting with an underscore are reserved for
  special keywords.)</p>
    <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="valid browsing context names or keywords|valid browsing context name or keyword" data-noexport="" id="valid-browsing-context-names-or-keywords">valid browsing context name or keyword</dfn> is any string that is either a <a data-link-type="dfn" href="browsers.html#valid-browsing-context-name" id="ref-for-valid-browsing-context-name-3">valid
  browsing context name</a> or that is an <a data-link-type="dfn" href="infrastructure.html#ascii-case-insensitive" id="ref-for-ascii-case-insensitive-52">ASCII case-insensitive</a> match for one of: <code>_blank</code>, <code>_self</code>, <code>_parent</code>, or <code>_top</code>.</p>
    <p>These values have different meanings based on whether the page is sandboxed or not, as summarized
  in the following (non-normative) table. In this table, "current" means the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-146">browsing context</a> that the link or script is in, "parent" means the <a data-link-type="dfn" href="browsers.html#parent-browsing-context" id="ref-for-parent-browsing-context-15">parent browsing context</a> of the one the
  link or script is in, "top" means the <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-35">top-level browsing context</a> of the one the link or
  script is in, "new" means a new <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-36">top-level browsing context</a> or <a data-link-type="dfn" href="browsers.html#auxiliary-browsing-contexts" id="ref-for-auxiliary-browsing-contexts-5">auxiliary browsing context</a> is to be created, subject to various user preferences and user
  agent policies, "none" means that nothing will happen, and "maybe new" means the same as "new" if
  the "<code>allow-popups</code>" keyword is also specified on the <code><a data-link-type="element-sub" href="semantics-embedded-content.html#element-attrdef-iframe-sandbox" id="ref-for-element-attrdef-iframe-sandbox-16">sandbox</a></code> attribute
  (or if the user overrode the sandboxing), and the same as "none" otherwise.</p>
    <table>
     <thead>
      <tr>
       <th rowspan="2">Keyword 
       </th><th rowspan="2">Ordinary effect 
       </th><th colspan="2">Effect in an <code>iframe</code> with... 
      </th></tr><tr>
       <th><code>sandbox=""</code> 
       </th><th><code>sandbox="allow-top-navigation"</code> 
     </th></tr></thead><tbody>
      <tr>
       <td>none specified, for links and <a data-link-type="dfn" href="sec-forms.html#form-submission" id="ref-for-form-submission-16">form submissions</a> 
       </td><td>current 
       </td><td>current 
       </td><td>current 
      </td></tr><tr>
       <td>empty string 
       </td><td>current 
       </td><td>current 
       </td><td>current 
      </td></tr><tr>
       <td><code>_blank</code> 
       </td><td>new 
       </td><td>maybe new 
       </td><td>maybe new 
      </td></tr><tr>
       <td><code>_self</code> 
       </td><td>current 
       </td><td>current 
       </td><td>current 
      </td></tr><tr>
       <td><code>_parent</code> if there isn’t a parent 
       </td><td>current 
       </td><td>current 
       </td><td>current 
      </td></tr><tr>
       <td><code>_parent</code> if parent is also top 
       </td><td>parent/top 
       </td><td>none 
       </td><td>parent/top 
      </td></tr><tr>
       <td><code>_parent</code> if there is one and it’s not top 
       </td><td>parent 
       </td><td>none 
       </td><td>none 
      </td></tr><tr>
       <td><code>_top</code> if top is current 
       </td><td>current 
       </td><td>current 
       </td><td>current 
      </td></tr><tr>
       <td><code>_top</code> if top is not current 
       </td><td>top 
       </td><td>none 
       </td><td>top 
      </td></tr><tr>
       <td>name that doesn’t exist 
       </td><td>new 
       </td><td>maybe new 
       </td><td>maybe new 
      </td></tr><tr>
       <td>name that exists and is a descendant 
       </td><td>specified descendant 
       </td><td>specified descendant 
       </td><td>specified descendant 
      </td></tr><tr>
       <td>name that exists and is current 
       </td><td>current 
       </td><td>current 
       </td><td>current 
      </td></tr><tr>
       <td>name that exists and is an ancestor that is top 
       </td><td>specified ancestor 
       </td><td>none 
       </td><td>specified ancestor/top 
      </td></tr><tr>
       <td>name that exists and is an ancestor that is not top 
       </td><td>specified ancestor 
       </td><td>none 
       </td><td>none 
      </td></tr><tr>
       <td>other name that exists with common top 
       </td><td>specified 
       </td><td>none 
       </td><td>none 
      </td></tr><tr>
       <td>name that exists with different top, if familiar and <a data-link-type="dfn" href="browsers.html#one-permitted-sandboxed-navigator" id="ref-for-one-permitted-sandboxed-navigator-3">one permitted sandboxed navigator</a> 
       </td><td>specified 
       </td><td>specified 
       </td><td>specified 
      </td></tr><tr>
       <td>name that exists with different top, if familiar but not <a data-link-type="dfn" href="browsers.html#one-permitted-sandboxed-navigator" id="ref-for-one-permitted-sandboxed-navigator-4">one permitted sandboxed navigator</a> 
       </td><td>specified 
       </td><td>none 
       </td><td>none 
      </td></tr><tr>
       <td>name that exists with different top, not familiar 
       </td><td>new 
       </td><td>maybe new 
       </td><td>maybe new 
    </td></tr></tbody></table>
    <p><small>Most of the restrictions on sandboxed browsing contexts are applied by
  other algorithms, e.g., the <a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-37">navigation</a> algorithm, not <a data-link-type="dfn" href="browsers.html#the-rules-for-choosing-a-browsing-context-given-a-browsing-context-name" id="ref-for-the-rules-for-choosing-a-browsing-context-given-a-browsing-context-name-6">the rules
  for choosing a browsing context given a browsing context name</a> given below.</small></p>
    <div class="impl">
     <hr>
     <p>An algorithm is <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="allowed-to-show-a-popup">allowed to show a popup</dfn> if any of the following conditions is
  true:</p>
     <ul>
      <li>The <a data-link-type="dfn" href="webappapis.html#tasks" id="ref-for-tasks-63">task</a> in which the algorithm is running is currently
    processing an <a data-link-type="dfn" href="editing.html#activation-behavior" id="ref-for-activation-behavior-49">activation behavior</a> whose <code>click</code> event
    was <a data-link-type="dfn" href="infrastructure.html#trusted" id="ref-for-trusted-15">trusted</a>.
      </li><li>
       <p>The <a data-link-type="dfn" href="webappapis.html#tasks" id="ref-for-tasks-64">task</a> in which the algorithm is running is currently
    running the event listener for a <a data-link-type="dfn" href="infrastructure.html#trusted" id="ref-for-trusted-16">trusted</a> event whose
    type is in the following list:</p>
       <ul class="brief">
        <li><code>change</code>
        </li><li><code>click</code>
        </li><li><code>dblclick</code>
        </li><li><code>mouseup</code>
        </li><li><code>reset</code>
        </li><li><code>submit</code>
       </li></ul>
      </li><li>
       <p>The <a data-link-type="dfn" href="webappapis.html#tasks" id="ref-for-tasks-65">task</a> in which the algorithm is running was <a data-link-type="dfn" href="webappapis.html#queue-a-microtask" id="ref-for-queue-a-microtask-30">queued</a> by an algorithm that was <a data-link-type="dfn" href="browsers.html#allowed-to-show-a-popup" id="ref-for-allowed-to-show-a-popup-4">allowed to show a popup</a>,
    and the chain of such algorithms started within a user-agent defined timeframe.</p>
       <p class="example" id="example-a410a9e9"><a class="self-link" href="browsers.html#example-a410a9e9"></a> For example, if a user clicked a button, it might be acceptable for a popup
    to result from that after 4 seconds, but it would likely not be acceptable for a popup to result
    from that after 4 hours. </p>
     </li></ul>
     <hr>
     <p><dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="the-rules-for-choosing-a-browsing-context-given-a-browsing-context-name">The rules for choosing a browsing context given a browsing context name</dfn> are as
  follows. The rules assume that they are being applied in the context of a <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-147">browsing
  context</a>, as part of the execution of a <a data-link-type="dfn" href="webappapis.html#tasks" id="ref-for-tasks-66">task</a>.</p>
     <ol>
      <li>If the given browsing context name is the empty string or <code>_self</code>, then
    the chosen browsing context must be the current one.
      </li><li>If the given browsing context name is <code>_parent</code>, then the chosen
    browsing context must be the <a data-link-type="dfn" href="browsers.html#parent-browsing-context" id="ref-for-parent-browsing-context-16"><em>parent</em> browsing context</a> of the current one,
    unless there isn’t one, in which case the chosen browsing context must be the current browsing
    context.
      </li><li>If the given browsing context name is <code>_top</code>, then the chosen browsing
    context must be the <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-37">top-level browsing context</a> of the current one, if there is one,
    or else the current browsing context.
      </li><li>If the given browsing context name is not <code>_blank</code> and there exists a
    browsing context whose <a data-link-type="dfn" href="browsers.html#browsing-context-name" id="ref-for-browsing-context-name-10">name</a> is the same as the given
    browsing context name, and the current browsing context is familiar with that
    browsing context, and the user agent determines that the two browsing contexts are related
    enough that it is ok if they reach each other, then that browsing context must be the chosen
    one. If there are multiple matching browsing contexts, the user agent should select one in some
    arbitrary consistent manner, such as the most recently opened, most recently focused, or more
    closely related.
      </li><li>
        Otherwise, a new browsing context is being requested, and what happens depends on the user
    agent’s configuration and abilities — it is determined by the rules given for the first
    applicable option from the following list: 
       <dl class="switch">
        <dt>If the algorithm is not <a data-link-type="dfn" href="browsers.html#allowed-to-show-a-popup" id="ref-for-allowed-to-show-a-popup-5">allowed to show a popup</a> and the
      user agent has been configured to not show popups (i.e., the user agent has a "popup blocker"
      enabled)
        </dt><dd>
         <p>There is no chosen browsing context. The user agent may inform the user that a popup has
      been blocked.</p>
        </dd><dt><dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="prevents content from creating new auxiliary browsing contexts" data-noexport="" id="prevents-content-from-creating-new-auxiliary-browsing-contexts"></dfn>If the current browsing context’s <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-49">active document</a>’s <a data-link-type="dfn" href="browsers.html#active-sandboxing-flag-set" id="ref-for-active-sandboxing-flag-set-10">active sandboxing flag set</a> has the <a data-link-type="dfn" href="browsers.html#sandboxed-auxiliary-navigation-browsing-context-flag" id="ref-for-sandboxed-auxiliary-navigation-browsing-context-flag-1">sandboxed auxiliary navigation browsing
      context flag</a> set.
        </dt><dd>
         <p>Typically, there is no chosen browsing context.</p>
         <p>The user agent may offer to create a new <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-38">top-level browsing context</a> or reuse
      an existing <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-39">top-level browsing context</a>. If the user picks one of those options,
      then the designated browsing context must be the chosen one (the browsing context’s name isn’t
      set to the given browsing context name). The default behavior (if the user agent doesn’t
      offer the option to the user, or if the user declines to allow a browsing context to be used)
      must be that there must not be a chosen browsing context.</p>
         <p class="warning">If this case occurs, it means that an author has explicitly sandboxed the
      document that is trying to open a link.</p>
        </dd><dt><dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="causes the opener attribute to remain null" data-noexport="" id="causes-the-opener-attribute-to-remain-null"></dfn>If the user agent has been configured such that in this instance it will
      create a new browsing context, and the browsing context is being requested as part of <a data-link-type="dfn" href="links.html#follow-hyperlinks" id="ref-for-follow-hyperlinks-10">following a hyperlink</a> whose <a data-link-type="dfn" href="links.html#allowed-keywords-and-their-meanings" id="ref-for-allowed-keywords-and-their-meanings-13">link
      types</a> include the <code>noreferrer</code> keyword
        </dt><dd>
         A new <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-40">top-level browsing context</a> must be created. If the given browsing
      context name is not <code>_blank</code>, then the new top-level browsing context’s
      name must be the given browsing context name (otherwise, it has no name). The chosen browsing
      context must be this new browsing context. The creation of such a <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-148">browsing context</a> is <dfn data-dfn-type="dfn" data-noexport="" id="a-new-start-for-session-storage">a new start for session storage<a class="self-link" href="browsers.html#a-new-start-for-session-storage"></a></dfn>. 
         <p class="note" role="note"> If it is immediately <a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-38">navigated</a>, then the
      navigation will be done with <a data-link-type="dfn" href="browsers.html#replacement-must-be-enabled" id="ref-for-replacement-must-be-enabled-10">replacement enabled</a>. </p>
        </dd><dt>If the user agent has been configured such that in this instance it will create a new
      browsing context, and the <code>noreferrer</code> keyword doesn’t
      apply
        </dt><dd>
         A new <a data-link-type="dfn" href="browsers.html#auxiliary-browsing-contexts" id="ref-for-auxiliary-browsing-contexts-6">auxiliary browsing context</a> must be created, with the <a data-link-type="dfn" href="browsers.html#opener-browsing-context" id="ref-for-opener-browsing-context-6">opener
      browsing context</a> being the current one. If the given browsing context name is not <code>_blank</code>, then the new auxiliary browsing context’s name must be the given
      browsing context name (otherwise, it has no name). The chosen browsing context must be this new
      browsing context. 
         <p class="note" role="note"> If it is immediately <a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-39">navigated</a>, then the
      navigation will be done with <a data-link-type="dfn" href="browsers.html#replacement-must-be-enabled" id="ref-for-replacement-must-be-enabled-11">replacement enabled</a>. </p>
        </dd><dt>If the user agent has been configured such that in this instance it will reuse the current
      browsing context
        </dt><dd>The chosen browsing context is the current browsing context.
        </dd><dt>If the user agent has been configured such that in this instance it will not find a
      browsing context
        </dt><dd>There must not be a chosen browsing context.
       </dd></dl>
       <p>User agent implementors are encouraged to provide a way for users to configure the user agent
    to always reuse the current browsing context.</p>
       <p>If the current browsing context’s <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-50">active document</a>’s <a data-link-type="dfn" href="browsers.html#active-sandboxing-flag-set" id="ref-for-active-sandboxing-flag-set-11">active sandboxing flag
    set</a> has both the <a data-link-type="dfn" href="browsers.html#sandboxed-navigation-browsing-context-flag" id="ref-for-sandboxed-navigation-browsing-context-flag-3">sandboxed navigation browsing context flag</a> and <a data-link-type="dfn" href="browsers.html#sandbox-propagates-to-auxiliary-browsing-contexts-flag" id="ref-for-sandbox-propagates-to-auxiliary-browsing-contexts-flag-1">sandbox propagates to auxiliary browsing contexts flag</a> set, and the chosen browsing
    context picked above, if any, is a new browsing context, then all the flags that are set in the
    current browsing context’s <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-51">active document</a>’s <a data-link-type="dfn" href="browsers.html#active-sandboxing-flag-set" id="ref-for-active-sandboxing-flag-set-12">active sandboxing flag
    set</a> when the new browsing context is created must be set in the new browsing context’s <a data-link-type="dfn" href="browsers.html#popup-sandboxing-flag-set" id="ref-for-popup-sandboxing-flag-set-1">popup sandboxing flag set</a>, and the current browsing context must be set as the new
    browsing context’s <a data-link-type="dfn" href="browsers.html#one-permitted-sandboxed-navigator" id="ref-for-one-permitted-sandboxed-navigator-5">one permitted sandboxed navigator</a>.</p>
     </li></ol>
    </div>
    <h4 class="heading settled" data-level="6.1.6" id="script-settings-for-browsing-contexts"><span class="secno">6.1.6. </span><span class="content">Script settings for browsing contexts</span><a class="self-link" href="browsers.html#script-settings-for-browsing-contexts"></a></h4>
    <p>When the user agent is required to <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="set-up-a-browsing-context-environment-settings-object">set up a browsing context environment settings object</dfn>, given a JavaScript execution
  context <var>execution context</var>, it must run the following steps:</p>
    <ol>
     <li data-md="">
      <p>Let <var>realm</var> be the value of <var>execution context</var>’s Realm component.</p>
     </li><li data-md="">
      <p>Let <var>window</var> be <var>realm</var>’s <a data-link-type="dfn" href="webappapis.html#global-object" id="ref-for-global-object-1">global object</a>.</p>
     </li><li data-md="">
      <p>Let <var>url</var> be a copy of the <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a> of the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> with which <var>window</var> is associated.</p>
     </li><li data-md="">
      <p>Let <var>settings object</var> be a new <a data-link-type="dfn" href="webappapis.html#environment-settings-object" id="ref-for-environment-settings-object-12">environment settings object</a> whose algorithms are
  defined as follows:</p>
      <dl>
       <dt data-md="">
        <p>The <a data-link-type="dfn" href="webappapis.html#realm-execution-context" id="ref-for-realm-execution-context-1">realm execution context</a></p>
       </dt><dd data-md="">
        <p>Return <var>execution context</var>.</p>
       </dd><dt data-md="">
        <p>The <a data-link-type="dfn" href="webappapis.html#responsible-browsing-context" id="ref-for-responsible-browsing-context-1">responsible browsing context</a></p>
       </dt><dd data-md="">
        <p>Return the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-149">browsing context</a> with which <var>window</var> is associated.</p>
       </dd><dt data-md="">
        <p>The <a data-link-type="dfn" href="webappapis.html#responsible-event-loop" id="ref-for-responsible-event-loop-1">responsible event loop</a></p>
       </dt><dd data-md="">
        <p>Return the <a data-link-type="dfn" href="webappapis.html#event-loop" id="ref-for-event-loop-29">event loop</a> that is associated with the <a data-link-type="dfn" href="browsers.html#units-of-related-similar-origin-browsing-contexts" id="ref-for-units-of-related-similar-origin-browsing-contexts-3">unit of related similar-origin browsing contexts</a> to which <var>window</var>’s <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-150">browsing context</a> belongs.</p>
       </dd><dt data-md="">
        <p>The <a data-link-type="dfn" href="webappapis.html#responsible-document" id="ref-for-responsible-document-2">responsible document</a></p>
       </dt><dd data-md="">
        <p>Return the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> with which <var>window</var> is currently associated.</p>
       </dd><dt data-md="">
        <p>The <a data-link-type="dfn" href="webappapis.html#api-url-character-encoding" id="ref-for-api-url-character-encoding-2">API URL character encoding</a></p>
       </dt><dd data-md="">
        <p>Return the current <a data-link-type="dfn" href="infrastructure.html#character-encoding" id="ref-for-character-encoding-17">character encoding</a> of the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> with which <var>window</var> is currently associated.</p>
       </dd><dt data-md="">
        <p>The <a data-link-type="dfn" href="webappapis.html#api-base-url" id="ref-for-api-base-url-2">API base URL</a></p>
       </dt><dd data-md="">
        <p>Return the current <a data-link-type="dfn" href="infrastructure.html#document-base-url" id="ref-for-document-base-url-12">base URL</a> of the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> with which <var>window</var> is
  currently associated.</p>
       </dd><dt data-md="">
        <p>The <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-39">origin</a></p>
       </dt><dd data-md="">
        <p>Return the <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-40">origin</a> of the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> with which <var>window</var> is
  currently associated.</p>
       </dd><dt data-md="">
        <p>The <a data-link-type="dfn" href="webappapis.html#creation-url" id="ref-for-creation-url-1">creation URL</a></p>
       </dt><dd data-md="">
        <p>Return <var>url</var>.</p>
       </dd><dt data-md="">
        <p>The <a data-link-type="dfn" href="webappapis.html#settings-https-state" id="ref-for-settings-https-state-1">HTTPS state</a></p>
       </dt><dd data-md="">
        <p>Return the <a data-link-type="dfn" href="dom.html#document-https-state" id="ref-for-document-https-state-3">HTTPS state</a> of the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> with which <var>window</var> is currently associated.</p>
      </dd></dl>
     </li><li data-md="">
      <p>Set <var>realm</var>’s [[HostDefined]] field to <var>settings object</var>.</p>
     </li><li data-md="">
      <p>Return <var>settings object</var>.</p>
    </li></ol>
    <h3 class="heading settled" data-level="6.2" id="security-infrastructure-for-window-windowproxy-location"><span class="secno">6.2. </span><span class="content">Security infrastructure for <code>Window</code>, <code>WindowProxy</code>, and <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-2">Location</a></code> objects</span><a class="self-link" href="browsers.html#security-infrastructure-for-window-windowproxy-location"></a></h3>
    <p>Although typically objects cannot be accessed across origins, the web platform would not be true
  to itself if it did not have some legacy exceptions to that rule that the web depends upon.</p>
    <h4 class="heading settled" data-level="6.2.1" id="integration-with-idl"><span class="secno">6.2.1. </span><span class="content">Integration with IDL</span><a class="self-link" href="browsers.html#integration-with-idl"></a></h4>
    <p>When <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-perform-a-security-check">perform a security check</a> is invoked, with a <var>platformObject</var>, <var>realm</var>, <var>identifier</var>, and <var>type</var>, run these steps:</p>
    <ol>
     <li data-md="">
      <p>If <var>platformObject</var> is a <code class="idl"><a data-link-type="idl" href="browsers.html#window-window" id="ref-for-window-window-17">Window</a></code> or <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-3">Location</a></code> object, then:</p>
      <ol>
       <li data-md="">
        <p>Repeat for each <var>e</var> that is an element of <a data-link-type="dfn" href="browsers.html#crossoriginproperties" id="ref-for-crossoriginproperties-1">CrossOriginProperties</a>(<var>platformObject</var>):</p>
        <ol>
         <li data-md="">
          <p>If <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-samevalue">SameValue</a>(<var>e</var>.[[Property]], <var>identifier</var>) is true, then:</p>
          <ol>
           <li data-md="">
            <p>If <var>type</var> is "<code>method</code>" and <var>e</var> has neither
  [[NeedsGet]] nor [[NeedsGet]], then return.</p>
           </li><li data-md="">
            <p>Otherwise, if <var>type</var> is "<code>getter</code>" and <var>e</var>.[[NeedsGet]] is true, then return.</p>
           </li><li data-md="">
            <p>Otherwise, if <var>type</var> is "<code>setter</code>" and <var>e</var>.[[NeedsSet]] is true, then return.</p>
          </li></ol>
        </li></ol>
      </li></ol>
     </li><li data-md="">
      <p>If <a data-link-type="dfn" href="browsers.html#isplatformobjectsameorigin" id="ref-for-isplatformobjectsameorigin-1">IsPlatformObjectSameOrigin</a>(<var>platformObject</var>) is false, then throw a
  "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#securityerror">SecurityError</a></code>" <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/WebIDL-1/#idl-DOMException">DOMException</a></code>.</p>
    </li></ol>
    <h4 class="heading settled" data-level="6.2.2" id="shared-internal-slot-crossoriginpropertydescriptormap"><span class="secno">6.2.2. </span><span class="content">Shared internal slot: [[CrossOriginPropertyDescriptorMap]]</span><a class="self-link" href="browsers.html#shared-internal-slot-crossoriginpropertydescriptormap"></a></h4>
    <p><code class="idl"><a data-link-type="idl" href="browsers.html#window-window" id="ref-for-window-window-18">Window</a></code> and <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-4">Location</a></code> objects both have a [[<dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="crossoriginpropertydescriptormap">CrossOriginPropertyDescriptorMap</dfn>]]
  internal slot, whose value is initially an empty map.</p>
    <p class="note" role="note">The [[<a data-link-type="dfn" href="browsers.html#crossoriginpropertydescriptormap" id="ref-for-crossoriginpropertydescriptormap-1">CrossOriginPropertyDescriptorMap</a>]] internal slot contains a map with
  entries whose keys are (currentOrigin, objectOrigin, propertyKey)-tuples and values are property
  descriptors, as a memoization of what is visible to scripts when currentOrigin inspects a <code class="idl"><a data-link-type="idl" href="browsers.html#window-window" id="ref-for-window-window-19">Window</a></code> or <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-5">Location</a></code> object from objectOrigin. It is filled lazily by <a data-link-type="dfn" href="browsers.html#crossorigingetownpropertyhelper" id="ref-for-crossorigingetownpropertyhelper-1">CrossOriginGetOwnPropertyHelper</a>, which consults it on future lookups.</p>
    <p>User agents should allow a value held in the map to be garbage collected along with its
  corresponding key when nothing holds a reference to any part of the value. That is, as long as
  garbage collection is not observable.</p>
    <div class="example" id="example-071c9f9b">
     <a class="self-link" href="browsers.html#example-071c9f9b"></a> For example, with 
<pre class="highlight"><span class="kr">const</span> <span class="nx">href</span> <span class="o">=</span> <span class="nb">Object</span><span class="p">.</span><span class="nx">getOwnPropertyDescriptor</span><span class="p">(</span><span class="nx">crossOriginLocation</span><span class="p">,</span> <span class="s2">"href"</span><span class="p">).</span><span class="nx">set</span>
</pre>
     <p>the value and its corresponding key in the map cannot be garbage collected as that would be
  observable.</p>
    </div>
    <p>User agents may have an optimization whereby they remove key-value pairs from the map when <code class="idl"><a data-link-type="idl" href="browsers.html#dom-document-domain" id="ref-for-dom-document-domain-3">document.domain</a></code> is set. This is not observable as <code class="idl"><a data-link-type="idl" href="browsers.html#dom-document-domain" id="ref-for-dom-document-domain-4">document.domain</a></code> cannot revisit an earlier value.</p>
    <div class="example" id="example-8816b9bf"><a class="self-link" href="browsers.html#example-8816b9bf"></a> For example, setting <code class="idl"><a data-link-type="idl" href="browsers.html#dom-document-domain" id="ref-for-dom-document-domain-5">document.domain</a></code> to "<code>example.com</code>" on <code>www.example.com</code> means user agents can remove all key-value pairs from the map where
  part of the key is <code>www.example.com</code>, as that can never be part of the origin again and
  therefore the corresponding value could never be retrieved from the map. </div>
    <h4 class="heading settled" data-level="6.2.3" id="shared-abstract-operations"><span class="secno">6.2.3. </span><span class="content">Shared abstract operations</span><a class="self-link" href="browsers.html#shared-abstract-operations"></a></h4>
    <h5 class="heading settled" data-level="6.2.3.1" id="crossoriginproperties-algorithm"><span class="secno">6.2.3.1. </span><span class="content"><dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="crossoriginproperties">CrossOriginProperties</dfn> ( <var>O</var> )</span><a class="self-link" href="browsers.html#crossoriginproperties-algorithm"></a></h5>
    <ol>
     <li data-md="">
      <p>Assert: <var>O</var> is a <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-6">Location</a></code> or <code class="idl"><a data-link-type="idl" href="browsers.html#window-window" id="ref-for-window-window-20">Window</a></code> object.</p>
       2. If <var>O</var> is a <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-7">Location</a></code> object, then return 
<pre>      « {
          [[Property]]: "href",
          [[NeedsGet]]: false,
          [[NeedsSet]]: true
        },
        {
          [[Property]]: "replace"
        } »</pre>
       3. Let <var>crossOriginWindowProperties</var> be 
<pre>      « {
          [[Property]]: "window",
          [[NeedsGet]]: true,
          [[NeedsSet]]: false
        },
        {
          [[Property]]: "self",
          [[NeedsGet]]: true,
          [[NeedsSet]]: false
        },
        {
          [[Property]]: "location",
          [[NeedsGet]]: true,
          [[NeedsSet]]: true
        },
        {
          [[Property]]: "close"
        },
        {
          [[Property]]: "closed",
          [[NeedsGet]]: true,
          [[NeedsSet]]: false
        },
        {
          [[Property]]: "focus"
        },
        {
          [[Property]]: "blur"
        },
        {
          [[Property]]: "frames",
          [[NeedsGet]]: true,
          [[NeedsSet]]: false
        },
        {
          [[Property]]: "length",
          [[NeedsGet]]: true,
          [[NeedsSet]]: false
        },
        {
          [[Property]]: "top",
          [[NeedsGet]]: true,
          [[NeedsSet]]: false
        },
        {
          [[Property]]: "opener",
          [[NeedsGet]]: true,
          [[NeedsSet]]: false
        },
        {
          [[Property]]: "parent",
          [[NeedsGet]]: true,
          [[NeedsSet]]: false
        },
        {
          [[Property]]: "postMessage"
        } »</pre>
     </li><li data-md="">
      <p>Repeat for each <var>e</var> that is an element of the <a data-link-type="dfn" href="browsers.html#child-browsing-context-name-property-set" id="ref-for-child-browsing-context-name-property-set-1">child browsing context name property set</a>:</p>
      <ol>
       <li data-md="">
        <p>Add { [[Property]]: <var>e</var> } as the last element of <var>crossOriginWindowProperties</var>.</p>
      </li></ol>
     </li><li data-md="">
      <p>Return <var>crossOriginWindowProperties</var>.</p>
    </li></ol>
    <p class="note" role="note">Indexed properties do not need to be safelisted as they are handled directly by
  the <code class="idl"><a data-link-type="idl" href="browsers.html#windowproxy" id="ref-for-windowproxy-10">WindowProxy</a></code> object.</p>
    <h5 class="heading settled" data-level="6.2.3.2" id="isplatformobjectsameorigin-algorithm"><span class="secno">6.2.3.2. </span><span class="content"><dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="isplatformobjectsameorigin">IsPlatformObjectSameOrigin</dfn> ( <var>O</var> )</span><a class="self-link" href="browsers.html#isplatformobjectsameorigin-algorithm"></a></h5>
    <ol>
     <li data-md="">
      <p>Return true if the <a data-link-type="dfn" href="webappapis.html#current-settings-object" id="ref-for-current-settings-object-1">current settings object</a>’s <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-41">origin</a> is <a data-link-type="dfn" href="browsers.html#same-origin-domain" id="ref-for-same-origin-domain-5">same origin-domain</a> with <var>O</var>’s <a data-link-type="dfn" href="webappapis.html#relevant-settings-object" id="ref-for-relevant-settings-object-1">relevant settings object</a>’s <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-42">origin</a>, and false otherwise.</p>
    </li></ol>
    <h5 class="heading settled" data-level="6.2.3.3" id="crossorigingetownpropertyhelper-algorithm"><span class="secno">6.2.3.3. </span><span class="content"><dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="crossorigingetownpropertyhelper">CrossOriginGetOwnPropertyHelper</dfn> ( <var>O</var>, <var>P</var> )</span><a class="self-link" href="browsers.html#crossorigingetownpropertyhelper-algorithm"></a></h5>
    <p class="note" role="note">If this abstract operation returns undefined and there is no custom behavior, the
  caller needs to throw a "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#securityerror">SecurityError</a></code>" <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/WebIDL-1/#idl-DOMException">DOMException</a></code>.</p>
    <ol>
     <li data-md="">
      <p>If <var>P</var> is <a data-link-type="dfn" href="infrastructure.html#tostringtag" id="ref-for-tostringtag-1">@@toStringTag</a>, <a data-link-type="dfn" href="infrastructure.html#hasinstance" id="ref-for-hasinstance-1">@@hasInstance</a>, or <a data-link-type="dfn" href="infrastructure.html#isconcatspreadable" id="ref-for-isconcatspreadable-1">@@isConcatSpreadable</a>,
  then return <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-property-descriptor-specification-type">PropertyDescriptor</a> { [[Value]]: undefined, [[Writable]]: false, [[Enumerable]]: false,
  [[Configurable]]: true }.</p>
     </li><li data-md="">
      <p>Let <var>crossOriginKey</var> be a tuple consisting of the <a data-link-type="dfn" href="webappapis.html#current-settings-object" id="ref-for-current-settings-object-2">current settings object</a>’s <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-43">origin</a>’s <a data-link-type="dfn" href="browsers.html#effective-domain" id="ref-for-effective-domain-1">effective domain</a>, <var>O</var>’s relevant settings
  object’s <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-44">origin</a>’s <a data-link-type="dfn" href="browsers.html#effective-domain" id="ref-for-effective-domain-2">effective domain</a>, and <var>P</var>.</p>
     </li><li data-md="">
      <p>Repeat for each <var>e</var> that is an element of <a data-link-type="dfn" href="browsers.html#crossoriginproperties" id="ref-for-crossoriginproperties-2">CrossOriginProperties</a>(<var>O</var>):</p>
      <ol>
       <li data-md="">
        <p>If <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-samevalue">SameValue</a>(<var>e</var>.[[Property]], <var>P</var>) is true, then:</p>
        <ol>
         <li data-md="">
          <p>If the value of the [[<a data-link-type="dfn" href="browsers.html#crossoriginpropertydescriptormap" id="ref-for-crossoriginpropertydescriptormap-2">CrossOriginPropertyDescriptorMap</a>]] internal slot of <var>O</var> contains an entry whose key is <var>crossOriginKey</var>, then return that
 entry’s value.</p>
         </li><li data-md="">
          <p>Let <var>originalDesc</var> be <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-ordinarygetownproperty">OrdinaryGetOwnProperty</a>(<var>O</var>, <var>P</var>).</p>
         </li><li data-md="">
          <p>Let <var>crossOriginDesc</var> be <a data-link-type="dfn" href="browsers.html#crossoriginpropertydescriptor" id="ref-for-crossoriginpropertydescriptor-1">CrossOriginPropertyDescriptor</a>(<var>e</var>, <var>originalDesc</var>).</p>
         </li><li data-md="">
          <p>Create an entry in the value of the [[<a data-link-type="dfn" href="browsers.html#crossoriginpropertydescriptormap" id="ref-for-crossoriginpropertydescriptormap-3">CrossOriginPropertyDescriptorMap</a>]]
 internal slot of <var>O</var> with key <var>crossOriginKey</var> and value <var>crossOriginDesc</var>.</p>
         </li><li data-md="">
          <p>Return <var>crossOriginDesc</var>.</p>
        </li></ol>
      </li></ol>
     </li><li data-md="">
      <p>Return undefined.</p>
    </li></ol>
    <h6 class="heading settled" data-level="6.2.3.3.1" id="crossoriginpropertydescriptor-algorithm"><span class="secno">6.2.3.3.1. </span><span class="content"><dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="crossoriginpropertydescriptor">CrossOriginPropertyDescriptor</dfn> ( <var>crossOriginProperty</var>, <var>originalDesc</var> )</span><a class="self-link" href="browsers.html#crossoriginpropertydescriptor-algorithm"></a></h6>
    <ol>
     <li data-md="">
      <p>If <var>crossOriginProperty</var>.[[NeedsGet]] and <var>crossOriginProperty</var>.[[NeedsSet]] are absent, then:</p>
      <ol>
       <li data-md="">
        <p>Let <var>value</var> be <var>originalDesc</var>.[[Value]].</p>
       </li><li data-md="">
        <p>If <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-iscallable">IsCallable</a>(<var>value</var>) is true, set <var>value</var> to <a data-link-type="dfn" href="browsers.html#crossoriginfunctionwrapper" id="ref-for-crossoriginfunctionwrapper-1">CrossOriginFunctionWrapper</a>(true, <var>value</var>).</p>
       </li><li data-md="">
        <p>Return <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-property-descriptor-specification-type">PropertyDescriptor</a>{ [[Value]]: <var>value</var>, [[Enumerable]]: false,
  [[Writable]]: false, [[Configurable]]: true }.</p>
      </li></ol>
     </li><li data-md="">
      <p>Otherwise:</p>
      <ol>
       <li data-md="">
        <p>Let <var>crossOriginGet</var> be <a data-link-type="dfn" href="browsers.html#crossoriginfunctionwrapper" id="ref-for-crossoriginfunctionwrapper-2">CrossOriginFunctionWrapper</a>(<var>crossOriginProperty</var>.[[NeedsGet]], <var>originalDesc</var>.[[Get]]).</p>
       </li><li data-md="">
        <p>Let <var>crossOriginSet</var> be <a data-link-type="dfn" href="browsers.html#crossoriginfunctionwrapper" id="ref-for-crossoriginfunctionwrapper-3">CrossOriginFunctionWrapper</a>(<var>crossOriginProperty</var>.[[NeedsSet]], <var>originalDesc</var>.[[Set]]).</p>
       </li><li data-md="">
        <p>Return <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-property-descriptor-specification-type">PropertyDescriptor</a>{ [[Get]]: <var>crossOriginGet</var>,
  [[Set]]: <var>crossOriginSet</var>, [[Enumerable]]: false, [[Configurable]]: true }.</p>
      </li></ol>
    </li></ol>
    <h6 class="heading settled" data-level="6.2.3.3.2" id="crossoriginfunctionwrapper-algorithm"><span class="secno">6.2.3.3.2. </span><span class="content"><dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="crossoriginfunctionwrapper">CrossOriginFunctionWrapper</dfn> ( <var>needsWrapping</var>, <var>functionToWrap</var> )</span><a class="self-link" href="browsers.html#crossoriginfunctionwrapper-algorithm"></a></h6>
    <ol>
     <li data-md="">
      <p>If <var>needsWrapping</var> is false, then return undefined.</p>
     </li><li data-md="">
      <p>Return a new <a data-link-type="dfn" href="browsers.html#cross-origin-wrapper-function" id="ref-for-cross-origin-wrapper-function-1">cross-origin wrapper function</a> whose [[Wrapped]] internal slot is <var>functionToWrap</var>.</p>
    </li></ol>
    <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="cross-origin-wrapper-function">cross-origin wrapper function</dfn> is an anonymous built-in function that has a
  [[Wrapped]] internal slot.</p>
    <p>When a <a data-link-type="dfn" href="browsers.html#cross-origin-wrapper-function" id="ref-for-cross-origin-wrapper-function-2">cross-origin wrapper function</a> <var>F</var> is called with a list of arguments <var>argumentsList</var>, the following steps are taken:</p>
    <ol>
     <li data-md="">
      <p>Assert: <var>F</var> has a [[Wrapped]] internal slot that is a function.</p>
     </li><li data-md="">
      <p>Let <var>wrappedFunction</var> be the [[Wrapped]] internal slot of <var>F</var>.</p>
     </li><li data-md="">
      <p>Return <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-call">Call</a>(<var>wrappedFunction</var>, this, <var>argumentsList</var>).</p>
    </li></ol>
    <p class="note" role="note">Due to this being invoked from a different <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-45">origin</a>, a <a data-link-type="dfn" href="browsers.html#cross-origin-wrapper-function" id="ref-for-cross-origin-wrapper-function-3">cross-origin wrapper function</a> will have a different value for <code>Function.prototype</code> from the function being wrapped. This follows from how JavaScript
  creates anonymous built-in functions.</p>
    <h5 class="heading settled" data-level="6.2.3.4" id="crossoriginget-algorithm"><span class="secno">6.2.3.4. </span><span class="content"><dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="crossoriginget">CrossOriginGet</dfn> ( <var>O</var>, <var>P</var>, <var>Receiver</var> )</span><a class="self-link" href="browsers.html#crossoriginget-algorithm"></a></h5>
    <ol>
     <li data-md="">
      <p>Let <var>desc</var> be <var>O</var>.[[GetOwnProperty]](<var>P</var>).</p>
     </li><li data-md="">
      <p>Assert: <var>desc</var> is not undefined.</p>
     </li><li data-md="">
      <p>If <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-isdatadescriptor">IsDataDescriptor</a>(<var>desc</var>) is true, then return <var>desc</var>.[[Value]].</p>
     </li><li data-md="">
      <p>Assert: <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-isaccessordescriptor">IsAccessorDescriptor</a>(<var>desc</var>) is true.</p>
     </li><li data-md="">
      <p>Let <var>getter</var> be <var>desc</var>.[[Get]].</p>
     </li><li data-md="">
      <p>If <var>getter</var> is undefined, throw a "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#securityerror">SecurityError</a></code>" <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/WebIDL-1/#idl-DOMException">DOMException</a></code>.</p>
     </li><li data-md="">
      <p>Return <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-call">Call</a>(<var>getter</var>, <var>Receiver</var>).</p>
    </li></ol>
    <h5 class="heading settled" data-level="6.2.3.5" id="crossoriginset-algorithm"><span class="secno">6.2.3.5. </span><span class="content"><dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="crossoriginset">CrossOriginSet</dfn> ( <var>O</var>, <var>P</var>, V, <var>Receiver</var> )</span><a class="self-link" href="browsers.html#crossoriginset-algorithm"></a></h5>
    <ol>
     <li data-md="">
      <p>Let <var>desc</var> be <var>O</var>.[[GetOwnProperty]](<var>P</var>).</p>
     </li><li data-md="">
      <p>Assert: <var>desc</var> is not undefined.</p>
     </li><li data-md="">
      <p>If <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-isaccessordescriptor">IsAccessorDescriptor</a>(<var>desc</var>) is true, then:</p>
      <ol>
       <li data-md="">
        <p>Let <var>setter</var> be <var>desc</var>.[[Set]].</p>
       </li><li data-md="">
        <p>If <var>setter</var> is undefined, return false.</p>
       </li><li data-md="">
        <p>Perform <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-call">Call</a>(<var>setter</var>, <var>Receiver</var>, «V»).</p>
       </li><li data-md="">
        <p>Return true.</p>
      </li></ol>
     </li><li data-md="">
      <p>Return false.</p>
    </li></ol>
    <h5 class="heading settled" data-level="6.2.3.6" id="crossoriginownpropertykeys-algorithm"><span class="secno">6.2.3.6. </span><span class="content"><dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="crossoriginownpropertykeys">CrossOriginOwnPropertyKeys</dfn> ( <var>O</var> )</span><a class="self-link" href="browsers.html#crossoriginownpropertykeys-algorithm"></a></h5>
    <ol>
     <li data-md="">
      <p>Let <var>keys</var> be a new empty <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-list-and-record-specification-type">List</a>.</p>
     </li><li data-md="">
      <p>Repeat for each <var>e</var> that is an element of <a data-link-type="dfn" href="browsers.html#crossoriginproperties" id="ref-for-crossoriginproperties-3">CrossOriginProperties</a>(<var>O</var>):</p>
      <ol>
       <li data-md="">
        <p>Add <var>e</var>.[[Property]] as the last element of <var>keys</var>.</p>
      </li></ol>
     </li><li data-md="">
      <p>Return <var>keys</var>.</p>
    </li></ol>
    <h3 class="heading settled" data-level="6.3" id="the-window-object"><span class="secno">6.3. </span><span class="content">The <code>Window</code> object</span><a class="self-link" href="browsers.html#the-window-object"></a></h3>
<pre class="idl highlight def" data-highlight="webidl">[<a class="nv idl-code" data-link-type="extended-attribute">PrimaryGlobal</a>, <a class="nv idl-code" data-link-type="extended-attribute">LegacyUnenumerableNamedProperties</a>]
/*sealed*/ <span class="kt">interface</span> <dfn class="nv dfn-paneled idl-code" data-dfn-for="Window" data-dfn-type="interface" data-export="" id="window-window">Window</dfn> : <a class="n" data-link-type="idl-name" href="https://www.w3.org/TR/dom/#eventtarget">EventTarget</a> {
// the current browsing context
[<a class="nv idl-code" data-link-type="extended-attribute">Unforgeable</a>] <span class="kt">readonly</span> <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="browsers.html#windowproxy" id="ref-for-windowproxy-11">WindowProxy</a> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="WindowProxy" href="browsers.html#dom-window-window" id="ref-for-dom-window-window-1">window</a>;
[<a class="nv idl-code" data-link-type="extended-attribute">Replaceable</a>] <span class="kt">readonly</span> <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="browsers.html#windowproxy" id="ref-for-windowproxy-12">WindowProxy</a> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="WindowProxy" href="browsers.html#dom-window-self" id="ref-for-dom-window-self-1">self</a>;
[<a class="nv idl-code" data-link-type="extended-attribute">Unforgeable</a>] <span class="kt">readonly</span> <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="https://www.w3.org/TR/dom/#document">Document</a> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="Document" href="browsers.html#dom-window-document" id="ref-for-dom-window-document-1">document</a>;
<span class="kt">attribute</span> <span class="kt">DOMString</span> <a class="nv idl-code" data-link-type="attribute" data-type="DOMString" href="browsers.html#dom-window-name" id="ref-for-dom-window-name-1">name</a>;
[<a class="nv idl-code" data-link-type="extended-attribute">PutForwards</a>=<a class="n idl-code" data-link-type="attribute" href="browsers.html#dom-location-href" id="ref-for-dom-location-href-2">href</a>, <a class="nv idl-code" data-link-type="extended-attribute">Unforgeable</a>] <span class="kt">readonly</span> <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="browsers.html#location-location" id="ref-for-location-location-8">Location</a> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="Location" href="browsers.html#dom-window-location" id="ref-for-dom-window-location-1">location</a>;
<span class="kt">readonly</span> <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="browsers.html#history-history" id="ref-for-history-history-1">History</a> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="History" href="browsers.html#dom-window-history" id="ref-for-dom-window-history-1">history</a>;
[<a class="nv idl-code" data-link-type="extended-attribute">Replaceable</a>] <span class="kt">readonly</span> <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="browsers.html#barprop-barprop" id="ref-for-barprop-barprop-1">BarProp</a> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="BarProp" href="browsers.html#dom-window-locationbar" id="ref-for-dom-window-locationbar-1">locationbar</a>;
[<a class="nv idl-code" data-link-type="extended-attribute">Replaceable</a>] <span class="kt">readonly</span> <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="browsers.html#barprop-barprop" id="ref-for-barprop-barprop-2">BarProp</a> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="BarProp" href="browsers.html#dom-window-menubar" id="ref-for-dom-window-menubar-1">menubar</a>;
[<a class="nv idl-code" data-link-type="extended-attribute">Replaceable</a>] <span class="kt">readonly</span> <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="browsers.html#barprop-barprop" id="ref-for-barprop-barprop-3">BarProp</a> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="BarProp" href="browsers.html#dom-window-personalbar" id="ref-for-dom-window-personalbar-1">personalbar</a>;
[<a class="nv idl-code" data-link-type="extended-attribute">Replaceable</a>] <span class="kt">readonly</span> <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="browsers.html#barprop-barprop" id="ref-for-barprop-barprop-4">BarProp</a> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="BarProp" href="browsers.html#dom-window-scrollbars" id="ref-for-dom-window-scrollbars-1">scrollbars</a>;
[<a class="nv idl-code" data-link-type="extended-attribute">Replaceable</a>] <span class="kt">readonly</span> <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="browsers.html#barprop-barprop" id="ref-for-barprop-barprop-5">BarProp</a> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="BarProp" href="browsers.html#dom-window-statusbar" id="ref-for-dom-window-statusbar-1">statusbar</a>;
[<a class="nv idl-code" data-link-type="extended-attribute">Replaceable</a>] <span class="kt">readonly</span> <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="browsers.html#barprop-barprop" id="ref-for-barprop-barprop-6">BarProp</a> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="BarProp" href="browsers.html#dom-window-toolbar" id="ref-for-dom-window-toolbar-1">toolbar</a>;
<span class="kt">attribute</span> <span class="kt">DOMString</span> <a class="nv idl-code" data-link-type="attribute" data-type="DOMString" href="browsers.html#dom-window-status" id="ref-for-dom-window-status-1">status</a>;
<span class="kt">void</span> <a class="nv idl-code" data-link-type="method" href="browsers.html#dom-window-close" id="ref-for-dom-window-close-1">close</a>();
<span class="kt">readonly</span> <span class="kt">attribute</span> <span class="kt">boolean</span> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="boolean" href="browsers.html#dom-window-closed" id="ref-for-dom-window-closed-1">closed</a>;
<span class="kt">void</span> <a class="nv idl-code" data-link-type="method" href="browsers.html#dom-window-stop" id="ref-for-dom-window-stop-1">stop</a>();
<span class="kt">void</span> <a class="nv idl-code" data-link-type="method" href="editing.html#dom-window-focus" id="ref-for-dom-window-focus-1">focus</a>();
<span class="kt">void</span> <a class="nv idl-code" data-link-type="method" href="editing.html#dom-window-blur" id="ref-for-dom-window-blur-1">blur</a>();

// other browsing contexts
[<a class="nv idl-code" data-link-type="extended-attribute">Replaceable</a>] <span class="kt">readonly</span> <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="browsers.html#windowproxy" id="ref-for-windowproxy-13">WindowProxy</a> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="WindowProxy" href="browsers.html#dom-window-frames" id="ref-for-dom-window-frames-1">frames</a>;
[<a class="nv idl-code" data-link-type="extended-attribute">Replaceable</a>] <span class="kt">readonly</span> <span class="kt">attribute</span> <span class="kt">unsigned</span> <span class="kt">long</span> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="unsigned long" href="browsers.html#dom-window-length" id="ref-for-dom-window-length-1">length</a>;
[<a class="nv idl-code" data-link-type="extended-attribute">Unforgeable</a>] <span class="kt">readonly</span> <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="browsers.html#windowproxy" id="ref-for-windowproxy-14">WindowProxy</a> <dfn class="nv dfn-paneled idl-code" data-dfn-for="Window" data-dfn-type="attribute" data-export="" data-readonly="" data-type="WindowProxy" id="dom-window-top">top</dfn>;
<span class="kt">attribute</span> <span class="kt">any</span> <dfn class="nv dfn-paneled idl-code" data-dfn-for="Window" data-dfn-type="attribute" data-export="" data-type="any" id="dom-window-opener">opener</dfn>;
[<a class="nv idl-code" data-link-type="extended-attribute">Replaceable</a>] <span class="kt">readonly</span> <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="browsers.html#windowproxy" id="ref-for-windowproxy-15">WindowProxy</a> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="WindowProxy" href="browsers.html#dom-window-parent" id="ref-for-dom-window-parent-1">parent</a>;
<span class="kt">readonly</span> <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="https://www.w3.org/TR/dom/#interface-element">Element</a>? <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="Element?" href="browsers.html#dom-window-frameelement" id="ref-for-dom-window-frameelement-1">frameElement</a>;
<a class="n" data-link-type="idl-name" href="browsers.html#windowproxy" id="ref-for-windowproxy-16">WindowProxy</a> <a class="nv idl-code" data-link-type="method" href="browsers.html#dom-window-open" id="ref-for-dom-window-open-1">open</a>(<span class="kt">optional</span> <span class="kt">DOMString</span> <dfn class="nv idl-code" data-dfn-for="Window/open(url, target, features, replace), Window/open(url, target, features), Window/open(url, target), Window/open(url), Window/open()" data-dfn-type="argument" data-export="" id="dom-window-open-url-target-features-replace-url">url<a class="self-link" href="browsers.html#dom-window-open-url-target-features-replace-url"></a></dfn> = "about:blank", <span class="kt">optional</span> <span class="kt">DOMString</span> <dfn class="nv idl-code" data-dfn-for="Window/open(url, target, features, replace), Window/open(url, target, features), Window/open(url, target), Window/open(url), Window/open()" data-dfn-type="argument" data-export="" id="dom-window-open-url-target-features-replace-target">target<a class="self-link" href="browsers.html#dom-window-open-url-target-features-replace-target"></a></dfn> = "_blank", [<a class="nv idl-code" data-link-type="extended-attribute">TreatNullAs</a>=<a class="n" data-link-type="idl-name" href="https://www.w3.org/TR/WebIDL-1/#TreatNullAs">EmptyString</a>] <span class="kt">optional</span> <span class="kt">DOMString</span> <dfn class="nv idl-code" data-dfn-for="Window/open(url, target, features, replace), Window/open(url, target, features), Window/open(url, target), Window/open(url), Window/open()" data-dfn-type="argument" data-export="" id="dom-window-open-url-target-features-replace-features">features<a class="self-link" href="browsers.html#dom-window-open-url-target-features-replace-features"></a></dfn> = "", <span class="kt">optional</span> <span class="kt">boolean</span> <dfn class="nv idl-code" data-dfn-for="Window/open(url, target, features, replace), Window/open(url, target, features), Window/open(url, target), Window/open(url), Window/open()" data-dfn-type="argument" data-export="" id="dom-window-open-url-target-features-replace-replace">replace<a class="self-link" href="browsers.html#dom-window-open-url-target-features-replace-replace"></a></dfn> = <span class="kt">false</span>);
<span class="kt">getter</span> <a class="n" data-link-type="idl-name" href="browsers.html#windowproxy" id="ref-for-windowproxy-17">WindowProxy</a> (<span class="kt">unsigned</span> <span class="kt">long</span> <dfn class="nv idl-code" data-dfn-for="Window/__getter__(index)" data-dfn-type="argument" data-export="" id="dom-window-__getter__-index-index">index<a class="self-link" href="browsers.html#dom-window-__getter__-index-index"></a></dfn>);
<span class="kt">getter</span> <span class="kt">object</span> (<span class="kt">DOMString</span> <dfn class="nv idl-code" data-dfn-for="Window/__getter__(name)" data-dfn-type="argument" data-export="" id="dom-window-__getter__-name-name">name<a class="self-link" href="browsers.html#dom-window-__getter__-name-name"></a></dfn>);

// the user agent
<span class="kt">readonly</span> <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="webappapis.html#navigator-navigator" id="ref-for-navigator-navigator-1">Navigator</a> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="Navigator" href="webappapis.html#dom-window-navigator" id="ref-for-dom-window-navigator-1">navigator</a>;

// user prompts
<span class="kt">void</span> <a class="nv idl-code" data-link-type="method" href="webappapis.html#dom-window-alert" id="ref-for-dom-window-alert-1">alert</a>();
<span class="kt">void</span> <a class="nv idl-code" data-link-type="method" href="webappapis.html#dom-window-alert" id="ref-for-dom-window-alert-2">alert</a>(<span class="kt">DOMString</span> <dfn class="nv idl-code" data-dfn-for="Window/alert(message)" data-dfn-type="argument" data-export="" id="dom-window-alert-message-message">message<a class="self-link" href="browsers.html#dom-window-alert-message-message"></a></dfn>);
<span class="kt">boolean</span> <a class="nv idl-code" data-link-type="method" href="webappapis.html#dom-window-confirm" id="ref-for-dom-window-confirm-1">confirm</a>(<span class="kt">optional</span> <span class="kt">DOMString</span> <dfn class="nv idl-code" data-dfn-for="Window/confirm(message), Window/confirm()" data-dfn-type="argument" data-export="" id="dom-window-confirm-message-message">message<a class="self-link" href="browsers.html#dom-window-confirm-message-message"></a></dfn> = "");
<span class="kt">DOMString</span>? <a class="nv idl-code" data-link-type="method" href="webappapis.html#dom-window-prompt" id="ref-for-dom-window-prompt-1">prompt</a>(<span class="kt">optional</span> <span class="kt">DOMString</span> <dfn class="nv idl-code" data-dfn-for="Window/prompt(message, default), Window/prompt(message), Window/prompt()" data-dfn-type="argument" data-export="" id="dom-window-prompt-message-default-message">message<a class="self-link" href="browsers.html#dom-window-prompt-message-default-message"></a></dfn> = "", <span class="kt">optional</span> <span class="kt">DOMString</span> <dfn class="nv idl-code" data-dfn-for="Window/prompt(message, default), Window/prompt(message), Window/prompt()" data-dfn-type="argument" data-export="" id="dom-window-prompt-message-default-default">default<a class="self-link" href="browsers.html#dom-window-prompt-message-default-default"></a></dfn> = "");
<span class="kt">void</span> <a class="nv idl-code" data-link-type="method" href="webappapis.html#dom-window-print" id="ref-for-dom-window-print-1">print</a>();
<span class="kt">any</span> <a class="nv idl-code" data-link-type="method" href="webappapis.html#dom-window-showmodaldialog" id="ref-for-dom-window-showmodaldialog-1">showModalDialog</a>(<span class="kt">DOMString</span> <dfn class="nv idl-code" data-dfn-for="Window/showModalDialog(url, argument), Window/showModalDialog(url)" data-dfn-type="argument" data-export="" id="dom-window-showmodaldialog-url-argument-url">url<a class="self-link" href="browsers.html#dom-window-showmodaldialog-url-argument-url"></a></dfn>, <span class="kt">optional</span> <span class="kt">any</span> <dfn class="nv idl-code" data-dfn-for="Window/showModalDialog(url, argument), Window/showModalDialog(url)" data-dfn-type="argument" data-export="" id="dom-window-showmodaldialog-url-argument-argument">argument<a class="self-link" href="browsers.html#dom-window-showmodaldialog-url-argument-argument"></a></dfn>); // deprecated

<span class="kt">unsigned</span> <span class="kt">long</span> <a class="nv idl-code" data-link-type="method" href="webappapis.html#dom-window-requestanimationframe" id="ref-for-dom-window-requestanimationframe-1">requestAnimationFrame</a>(<a class="n" data-link-type="idl-name" href="browsers.html#callbackdef-window-framerequestcallback" id="ref-for-callbackdef-window-framerequestcallback-1">FrameRequestCallback</a> <dfn class="nv idl-code" data-dfn-for="Window/requestAnimationFrame(callback)" data-dfn-type="argument" data-export="" id="dom-window-requestanimationframe-callback-callback">callback<a class="self-link" href="browsers.html#dom-window-requestanimationframe-callback-callback"></a></dfn>);
<span class="kt">void</span> <a class="nv idl-code" data-link-type="method" href="webappapis.html#dom-window-cancelanimationframe" id="ref-for-dom-window-cancelanimationframe-1">cancelAnimationFrame</a>(<span class="kt">unsigned</span> <span class="kt">long</span> <dfn class="nv idl-code" data-dfn-for="Window/cancelAnimationFrame(handle)" data-dfn-type="argument" data-export="" id="dom-window-cancelanimationframe-handle-handle">handle<a class="self-link" href="browsers.html#dom-window-cancelanimationframe-handle-handle"></a></dfn>);
};
<a class="n" data-link-type="idl-name" href="browsers.html#window-window" id="ref-for-window-window-21">Window</a> <span class="kt">implements</span> <a class="n" data-link-type="idl-name" href="webappapis.html#globaleventhandlers-globaleventhandlers" id="ref-for-globaleventhandlers-globaleventhandlers-3">GlobalEventHandlers</a>;
<a class="n" data-link-type="idl-name" href="browsers.html#window-window" id="ref-for-window-window-22">Window</a> <span class="kt">implements</span> <a class="n" data-link-type="idl-name" href="webappapis.html#windoweventhandlers-windoweventhandlers" id="ref-for-windoweventhandlers-windoweventhandlers-2">WindowEventHandlers</a>;

<span class="kt">callback</span> <dfn class="nv dfn-paneled idl-code" data-dfn-for="Window" data-dfn-type="callback" data-export="" id="callbackdef-window-framerequestcallback">FrameRequestCallback</dfn> = <span class="kt">void</span> (<a class="n" data-link-type="idl-name" href="https://www.w3.org/TR/hr-time/#dom-domhighrestimestamp">DOMHighResTimeStamp</a> <dfn class="nv idl-code" data-dfn-for="FrameRequestCallback" data-dfn-type="argument" data-export="" id="dom-framerequestcallback-time">time<a class="self-link" href="browsers.html#dom-framerequestcallback-time"></a></dfn>);
</pre>
    <dl class="domintro">
     <dt><var>window</var> . <code>window</code>
     </dt><dt><var>window</var> . <code>frames</code>
     </dt><dt><var>window</var> . <code>self</code>
     </dt><dd>
      <p>These attributes all return <var>window</var>.</p>
     </dd><dt><var>window</var> . <code>document</code>
     </dt><dd>
      <p>Returns the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> associated with <var>window</var>.</p>
     </dd><dt><var>document</var> . <code>defaultView</code>
     </dt><dd>
      <p>Returns the <code>Window</code> object of the <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-52">active document</a>.</p>
    </dd></dl>
    <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="Window" data-dfn-type="attribute" data-export="" id="dom-window-window"><code>window</code></dfn>, <dfn class="dfn-paneled idl-code" data-dfn-for="Window" data-dfn-type="attribute" data-export="" id="dom-window-frames"><code>frames</code></dfn>, and <dfn class="dfn-paneled idl-code" data-dfn-for="Window" data-dfn-type="attribute" data-export="" id="dom-window-self"><code>self</code></dfn> IDL attributes must all return the <code class="idl"><a data-link-type="idl" href="browsers.html#window-window" id="ref-for-window-window-23">Window</a></code> object’s <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-151">browsing context</a>’s <code class="idl"><a data-link-type="idl" href="browsers.html#windowproxy" id="ref-for-windowproxy-18">WindowProxy</a></code> object.</p>
    <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="Window" data-dfn-type="attribute" data-export="" id="dom-window-document"><code>document</code></dfn> IDL attribute must return <a data-link-type="dfn" href="browsers.html#document-associated-with-a-window" id="ref-for-document-associated-with-a-window-2">the <code>Window</code> object’s newest <code>Document</code> object</a>.</p>
    <p class="note" role="note">The <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object associated with a <code>Window</code> object can change in
  exactly one case: when the <a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-40">navigate</a> algorithm initializes a new <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object for the
  first page loaded in a <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-152">browsing context</a>. In that specific case, the <code class="idl"><a data-link-type="idl" href="browsers.html#window-window" id="ref-for-window-window-24">Window</a></code> object of
  the original <a data-link-type="scheme" href="infrastructure.html#schemedef-about" id="ref-for-schemedef-about-6">about:blank</a> page is reused and gets a new <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object.</p>
    <p>The <dfn class="idl-code" data-dfn-for="Window" data-dfn-type="attribute" data-export="" id="dom-window-defaultview"><code>defaultView</code><a class="self-link" href="browsers.html#dom-window-defaultview"></a></dfn> IDL attribute of the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> interface must return the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-153">browsing context</a>’s <code class="idl"><a data-link-type="idl" href="browsers.html#windowproxy" id="ref-for-windowproxy-19">WindowProxy</a></code> object, if
  there is one, or null otherwise.</p>
    <hr>
    <p>For historical reasons, <code class="idl"><a data-link-type="idl" href="browsers.html#window-window" id="ref-for-window-window-25">Window</a></code> objects must also have a writable, configurable,
  non-enumerable property named <dfn data-dfn-type="dfn" data-noexport="" id="htmldocument"><code>HTMLDocument</code><a class="self-link" href="browsers.html#htmldocument"></a></dfn> whose value is the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> interface object.</p>
    <h4 class="heading settled" data-level="6.3.1" id="apis-for-creating-and-navigating-browsing-contexts-by-name"><span class="secno">6.3.1. </span><span class="content">APIs for creating and navigating browsing contexts by name</span><a class="self-link" href="browsers.html#apis-for-creating-and-navigating-browsing-contexts-by-name"></a></h4>
    <dl class="domintro">
     <dt><var>window</var> = <var>window</var> . <code>open</code>( [ <var>url</var> [, <var>target</var> [, <var>features</var> [, <var>replace</var> ] ] ] ] )
     </dt><dd>
      <p>Opens a window to show <var>url</var> (defaults to <code>about:blank</code>), and
    returns it. The <var>target</var> argument gives the name of the new window. If a
    window exists with that name already, it is reused. The <var>replace</var> attribute,
    if true, means that whatever page is currently open in that window will be removed from the
    window’s session history. The <var>features</var> argument can be used to influence the rendering of the new window.</p>
     </dd><dt><var>window</var> . <code>name</code> [ = <var>value</var> ]
     </dt><dd>
      <p>Returns the name of the window.</p>
      <p>Can be set, to change the name.</p>
     </dd><dt><var>window</var> . <code>close</code>()
     </dt><dd>
      <p>Closes the window.</p>
     </dd><dt><var>window</var> . <code>closed</code>
     </dt><dd>
      <p>Returns true if the window has been closed, false otherwise.</p>
     </dd><dt><var>window</var> . <code>stop</code>()
     </dt><dd>
      <p>Cancels the document load.</p>
    </dd></dl>
    <div class="impl">
     <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="Window" data-dfn-type="method" data-export="" id="dom-window-open"><code>open()</code></dfn> method on <code>Window</code> objects
  provides a mechanism for <a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-41">navigating</a> an existing <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-154">browsing
  context</a> or opening and navigating an <a data-link-type="dfn" href="browsers.html#auxiliary-browsing-contexts" id="ref-for-auxiliary-browsing-contexts-7">auxiliary browsing context</a>.</p>
     <p>When the method is invoked, the user agent must run the following steps:</p>
     <ol>
      <li>Let <var>entry settings</var> be the <a data-link-type="dfn" href="webappapis.html#entry-settings-object" id="ref-for-entry-settings-object-6">entry settings object</a> when the method
    was invoked.
      </li><li>Let <var>url</var> be the first argument.
      </li><li>Let <var>target</var> be the second argument.
      </li><li>Let <var>features</var> be the third argument.
      </li><li>Let <var>replace</var> be the fourth argument.
      </li><li>Let <var>source browsing context</var> be the <a data-link-type="dfn" href="webappapis.html#responsible-browsing-context" id="ref-for-responsible-browsing-context-2">responsible browsing context</a> specified by <var>entry settings</var>.
      </li><li>If <var>target</var> is the empty string, let it be the string "<code>_blank</code>" instead.
      </li><li>
       <p>If the user has indicated a preference for which <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-155">browsing context</a> to navigate,
    follow these substeps:</p>
       <ol>
        <li>Let <var>target browsing context</var> be the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-156">browsing context</a> indicated by
      the user.
        </li><li>If <var>target browsing context</var> is a new <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-41">top-level browsing context</a>,
      let the <var>source browsing context</var> be set as <var>target browsing context</var>’s <a data-link-type="dfn" href="browsers.html#one-permitted-sandboxed-navigator" id="ref-for-one-permitted-sandboxed-navigator-6">one permitted sandboxed navigator</a>.
       </li></ol>
       <p class="example" id="example-2a9b28da"><a class="self-link" href="browsers.html#example-2a9b28da"></a> For example, suppose there is a user agent that supports control-clicking a
    link to open it in a new tab. If a user clicks in that user agent on an element whose <code>onclick</code> handler uses the <code>window.open()</code> API to open a page in an iframe, but, while doing so,
    holds the control key down, the user agent could override the selection of the target browsing
    context to instead target a new tab. </p>
       <p>Otherwise, apply <a data-link-type="dfn" href="browsers.html#the-rules-for-choosing-a-browsing-context-given-a-browsing-context-name" id="ref-for-the-rules-for-choosing-a-browsing-context-given-a-browsing-context-name-7">the rules for choosing a browsing context given a browsing context
    name</a> using <var>target</var> as the name and <var>source browsing context</var> as the
    context in which the algorithm is executed. If this results in there not being a chosen browsing
    context, then throw an <code>InvalidAccessError</code> exception and abort these steps.
    Otherwise, let <var>target browsing context</var> be the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-157">browsing context</a> so
    obtained.</p>
      </li><li>If <var>target browsing context</var> was just created, either as part of <a data-link-type="dfn" href="browsers.html#the-rules-for-choosing-a-browsing-context-given-a-browsing-context-name" id="ref-for-the-rules-for-choosing-a-browsing-context-given-a-browsing-context-name-8">the rules
    for choosing a browsing context given a browsing context name</a> or due to the user
    indicating a preference for navigating a new <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-42">top-level browsing context</a>, then let <var>new</var> be true. Otherwise, let it be false.
      </li><li>Interpret <var>features</var> as defined in the CSSOM View specification. <a data-link-type="biblio" href="references.html#biblio-cssom-view">[CSSOM-VIEW]</a>
      </li><li>
       <p>If <var>url</var> is the empty string, run the appropriate steps from the following list:</p>
       <dl>
        <dt>If <var>new</var> is false
        </dt><dd>Jump to the step labeled <i>end</i>.
        </dd><dt>If <var>new</var> is true
        </dt><dd>Let <var>resource</var> be the <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a> "<code>about:blank</code>".
       </dd></dl>
       <p>Otherwise, <a data-link-type="dfn" href="infrastructure.html#reparsed" id="ref-for-reparsed-35">parse</a> <var>url</var> relative to <var>entry settings</var>, and let <var>resource</var> be
    the <a data-link-type="dfn" href="infrastructure.html#resulting-url-record" id="ref-for-resulting-url-record-10">resulting URL record</a>, if any. If the <a data-link-type="dfn" href="infrastructure.html#reparsed" id="ref-for-reparsed-36">parse a URL</a> algorithm
    failed, then run one of the following two steps instead:</p>
       <ul>
        <li>Let <var>resource</var> be a resource representing an inline error page.
        </li><li>If <var>new</var> is false, jump to the step labeled <i>end</i>, otherwise, let <var>resource</var> be the <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a> "<code>about:blank</code>".
       </li></ul>
      </li><li>
       <p>If <var>resource</var> is "<code>about:blank</code>" and <var>new</var> is true, <a data-link-type="dfn" href="webappapis.html#queuing" id="ref-for-queuing-116">queue
    a task</a> to <a data-link-type="dfn" href="infrastructure.html#fire" id="ref-for-fire-144">fire a simple event</a> named <code>load</code> at <var>target browsing context</var>’s <code>Window</code> object, with <i>target override</i> set to <var>target browsing
    context</var>’s <code>Window</code> object’s <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object.</p>
       <p>Otherwise, <a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-42">navigate</a> <var>target browsing context</var> to <var>resource</var>, with the <a data-link-type="dfn" href="browsers.html#exceptions-enabled-flag" id="ref-for-exceptions-enabled-flag-2">exceptions enabled flag</a> set. If <var>new</var> is true, then <a data-link-type="dfn" href="browsers.html#replacement-must-be-enabled" id="ref-for-replacement-must-be-enabled-12">replacement must be enabled</a> also. The <a data-link-type="dfn" href="browsers.html#source-browsing-context" id="ref-for-source-browsing-context-9">source
    browsing context</a> is <var>source browsing context</var>.</p>
      </li><li><i>End</i>: Return the <code>WindowProxy</code> object of <var>target browsing
    context</var>.
     </li></ol>
     <hr>
     <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="Window" data-dfn-type="attribute" data-export="" id="dom-window-name"><code>name</code></dfn> attribute of the <code>Window</code> object
  must, on getting, return the current <a data-link-type="dfn" href="browsers.html#browsing-context-name" id="ref-for-browsing-context-name-11">name</a> of the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-158">browsing context</a>, if one is set, or the empty string otherwise; and, on setting, set
  the <a data-link-type="dfn" href="browsers.html#browsing-context-name" id="ref-for-browsing-context-name-12">name</a> of the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-159">browsing context</a> to the
  new value.</p>
     <p class="note" role="note"> The name <a data-link-type="dfn" href="browsers.html#gets-reset" id="ref-for-gets-reset-1">gets reset</a> when the browsing context is
  navigated to another domain. </p>
     <hr>
     <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="Window" data-dfn-type="method" data-export="" id="dom-window-close"><code>close()</code></dfn> method on <code>Window</code> objects should, if all the following conditions are met, <a data-link-type="dfn" href="browsers.html#close-a-browsing-context" id="ref-for-close-a-browsing-context-1">close</a> the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-160">browsing context</a> <var>A</var>:</p>
     <ul class="brief">
      <li>The corresponding <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-161">browsing context</a> <var>A</var> is <a data-link-type="dfn" href="browsers.html#script-closable" id="ref-for-script-closable-1">script-closable</a>.
      </li><li>The <a data-link-type="dfn" href="webappapis.html#responsible-browsing-context" id="ref-for-responsible-browsing-context-3">responsible browsing context</a> specified by the <a data-link-type="dfn" href="webappapis.html#incumbent-settings-object" id="ref-for-incumbent-settings-object-3">incumbent settings
    object</a> is familiar with the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-162">browsing context</a> <var>A</var>.
      </li><li>The <a data-link-type="dfn" href="webappapis.html#responsible-browsing-context" id="ref-for-responsible-browsing-context-4">responsible browsing context</a> specified by the <a data-link-type="dfn" href="webappapis.html#incumbent-settings-object" id="ref-for-incumbent-settings-object-4">incumbent settings object</a> is <a data-link-type="dfn" href="browsers.html#allowed-to-navigate" id="ref-for-allowed-to-navigate-1">allowed to navigate</a> the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-163">browsing
    context</a> <var>A</var>.
     </li></ul>
     <p>A <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-164">browsing context</a> is <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="script-closable">script-closable</dfn> if it is an <a data-link-type="dfn" href="browsers.html#auxiliary-browsing-contexts" id="ref-for-auxiliary-browsing-contexts-8">auxiliary
  browsing context</a> that was created by a script (as opposed to by an action of the user), or
  if it is a <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-43">top-level browsing context</a> whose <a data-link-type="dfn" href="browsers.html#session-history" id="ref-for-session-history-6">session history</a> contains
  only one <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>.</p>
     <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="Window" data-dfn-type="attribute" data-export="" id="dom-window-closed"><code>closed</code></dfn> attribute on <code>Window</code> objects must return true if the <code>Window</code> object’s <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-165">browsing context</a> has
  been <a data-link-type="dfn" href="browsers.html#a-browsing-context-is-discarded" id="ref-for-a-browsing-context-is-discarded-3">discarded</a>, and false otherwise.</p>
     <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="Window" data-dfn-type="method" data-export="" id="dom-window-stop"><code>stop()</code></dfn> method on <code>Window</code> objects should, if there is an existing attempt to <a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-43">navigate</a> the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-166">browsing
  context</a> and that attempt is not currently running the <a data-link-type="dfn" href="browsers.html#unloaded" id="ref-for-unloaded-2">unload a document</a> algorithm, cancel that <a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-44">navigation</a>; then, it must <a data-link-type="dfn" href="browsers.html#abort-the-document" id="ref-for-abort-the-document-2">abort</a> the <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-53">active document</a> of the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-167">browsing
  context</a> of the <code>Window</code> object on which it was invoked.</p>
    </div>
    <h4 class="heading settled" data-level="6.3.2" id="accessing-other-browsing-contexts"><span class="secno">6.3.2. </span><span class="content">Accessing other browsing contexts</span><a class="self-link" href="browsers.html#accessing-other-browsing-contexts"></a></h4>
    <dl class="domintro">
     <dt><var>window</var> . <code class="idl"><a data-link-type="idl" href="browsers.html#dom-window-length" id="ref-for-dom-window-length-2">length</a></code>
     </dt><dd>Returns the <a data-link-type="dfn" href="browsers.html#number-of-child-browsing-contexts" id="ref-for-number-of-child-browsing-contexts-1">number of child browsing contexts</a>.
     </dd><dt><var>window</var>[<var>index</var>]
     </dt><dd>Returns the indicated <a data-link-type="dfn" href="browsers.html#child-browsing-context" id="ref-for-child-browsing-context-16">child browsing context</a>.
    </dd></dl>
    <p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="number-of-child-browsing-contexts">number of child browsing contexts</dfn> of a <code class="idl"><a data-link-type="idl" href="browsers.html#window-window" id="ref-for-window-window-26">Window</a></code> object <var>W</var> is the number
  of <a data-link-type="dfn" href="browsers.html#child-browsing-context" id="ref-for-child-browsing-context-17">child browsing contexts</a> that are <a data-link-type="dfn" href="browsers.html#through-which-new-document-is-nested" id="ref-for-through-which-new-document-is-nested-3">nested through</a> elements that are in a <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> that is the <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-54">active document</a> of the <code class="idl"><a data-link-type="idl" href="browsers.html#window-window" id="ref-for-window-window-27">Window</a></code> object’s <a data-link-type="dfn" href="browsers.html#document-associated-with-a-window" id="ref-for-document-associated-with-a-window-3">associated</a> <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object’s <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-168">browsing context</a>.</p>
    <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="Window" data-dfn-type="attribute" data-export="" id="dom-window-length"><code>length</code></dfn> IDL attribute’s getter must return the <a data-link-type="dfn" href="browsers.html#number-of-child-browsing-contexts" id="ref-for-number-of-child-browsing-contexts-2">number of child browsing contexts</a> of this <code class="idl"><a data-link-type="idl" href="browsers.html#window-window" id="ref-for-window-window-28">Window</a></code> object.</p>
    <p class="note" role="note">Indexed access to <a data-link-type="dfn" href="browsers.html#child-browsing-context" id="ref-for-child-browsing-context-18">child browsing contexts</a> is defined through the <a data-link-type="dfn" href="browsers.html#windowproxy-getownproperty" id="ref-for-windowproxy-getownproperty-1">[[GetOwnProperty]]</a> internal method of the <code class="idl"><a data-link-type="idl" href="browsers.html#windowproxy" id="ref-for-windowproxy-20">WindowProxy</a></code> object.</p>
    <h4 class="heading settled" data-level="6.3.3" id="named-access-on-the-window-object"><span class="secno">6.3.3. </span><span class="content">Named access on the <code>Window</code> object</span><a class="self-link" href="browsers.html#named-access-on-the-window-object"></a></h4>
    <dl class="domintro">
     <dt><var>window</var>[<var>name</var>]
     </dt><dd>
      Returns the indicated element or collection of elements. 
      <p>As a general rule, relying on this will lead to brittle code. Which IDs end up mapping to
    this API can vary over time, as new features are added to the Web platform, for example. Instead
    of this, use <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#dom-nonelementparentnode-getelementbyid">document.getElementById()</a></code> or <code>document.querySelector()</code>.</p>
    </dd></dl>
    <p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="child-browsing-context-name-property-set">child browsing context name property set</dfn> consists of the <a data-link-type="dfn" href="browsers.html#browsing-context-name" id="ref-for-browsing-context-name-13">browsing context names</a> of any <a data-link-type="dfn" href="browsers.html#child-browsing-context" id="ref-for-child-browsing-context-19">child browsing context</a> of the <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-55">active document</a> whose name is not the empty string, with duplicates omitted.</p>
    <p>The <code>Window</code> interface <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-support-named-properties">supports named properties</a>.
  The <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-supported-property-names">supported property names</a> at any moment consist of the following, in <a data-link-type="dfn" href="infrastructure.html#tree-order" id="ref-for-tree-order-74">tree order</a>,
  ignoring later duplicates:</p>
    <ul>
     <li data-md="">
      <p>the <a data-link-type="dfn" href="browsers.html#child-browsing-context-name-property-set" id="ref-for-child-browsing-context-name-property-set-2">child browsing context name property set</a>.</p>
     </li><li data-md="">
      <p>the value of the <code>name</code> content attribute for all <code><a data-link-type="element" href="textlevel-semantics.html#elementdef-a" id="ref-for-elementdef-a-94">a</a></code>, <code><a data-link-type="element" href="obsolete.html#elementdef-applet" id="ref-for-elementdef-applet-4">applet</a></code>, <code><a data-link-type="element" href="semantics-embedded-content.html#elementdef-area" id="ref-for-elementdef-area-89">area</a></code>, <code><a data-link-type="element" href="semantics-embedded-content.html#elementdef-embed" id="ref-for-elementdef-embed-38">embed</a></code>, <code><a data-link-type="element" href="sec-forms.html#elementdef-form" id="ref-for-elementdef-form-94">form</a></code>, <code><a data-link-type="element" href="obsolete.html#elementdef-frameset" id="ref-for-elementdef-frameset-7">frameset</a></code>, <code><a data-link-type="element" href="semantics-embedded-content.html#elementdef-img" id="ref-for-elementdef-img-151">img</a></code>, and <code><a data-link-type="element" href="semantics-embedded-content.html#elementdef-object" id="ref-for-elementdef-object-76">object</a></code> elements in the <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-56">active document</a> that have a non-empty <code>name</code> content attribute, and</p>
     </li><li data-md="">
      <p>the value of the <code>id</code> content attribute of any <a data-link-type="dfn" href="infrastructure.html#html-element" id="ref-for-html-element-59">HTML element</a> in the <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-57">active document</a> with a non-empty <code>id</code> content attribute.</p>
    </li></ul>
    <p>To <a data-link-type="dfn" href="https://www.w3.org/TR/WebIDL/#dfn-determine-the-value-of-a-named-property">determine the value of a named property</a> <var>name</var> when <dfn data-dfn-type="dfn" data-noexport="" id="the-window-object-is-indexed-for-property-retrieval">the <code>Window</code> object is indexed for property retrieval<a class="self-link" href="browsers.html#the-window-object-is-indexed-for-property-retrieval"></a></dfn>, the user agent must
  return the value obtained using the following steps:</p>
    <ol>
     <li>
      <p>Let <var>objects</var> be the list of <a data-link-type="dfn" href="browsers.html#named-objects" id="ref-for-named-objects-1">named objects</a> with the name <var>name</var> in the <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-58">active document</a>.</p>
      <p class="note" role="note"> There will be at least one such object, by definition. </p>
     </li><li>
      <p>If <var>objects</var> contains a <a data-link-type="dfn" href="browsers.html#nested-browsing-contexts" id="ref-for-nested-browsing-contexts-62">nested browsing context</a>, then return
    the <code>WindowProxy</code> object of the <a data-link-type="dfn" href="browsers.html#nested-browsing-contexts" id="ref-for-nested-browsing-contexts-63">nested browsing context</a> corresponding to
    the first <a data-link-type="dfn" href="browsers.html#browsing-context-container" id="ref-for-browsing-context-container-27">browsing context container</a> in <a data-link-type="dfn" href="infrastructure.html#tree-order" id="ref-for-tree-order-75">tree order</a> whose <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-169">browsing context</a> is in <var>objects</var>, and abort these steps.</p>
     </li><li>
      <p>Otherwise, if <var>objects</var> has only one element, return that element and
    abort these steps.</p>
     </li><li>
      <p>Otherwise return an <code>HTMLCollection</code> rooted at the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> node,
    whose filter matches only <a data-link-type="dfn" href="browsers.html#named-objects" id="ref-for-named-objects-2">named objects</a> with
    the name <var>name</var>. (By definition, these will all be elements.)</p>
    </li></ol>
    <p><dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="named-objects">Named objects</dfn> with the name <var>name</var>, for the purposes of the above algorithm, are those that are either:</p>
    <ul>
     <li><a data-link-type="dfn" href="browsers.html#child-browsing-context" id="ref-for-child-browsing-context-20">child browsing contexts</a> of the <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-59">active
    document</a> whose name is <var>name</var>,
     </li><li><code><a data-link-type="element" href="textlevel-semantics.html#elementdef-a" id="ref-for-elementdef-a-95">a</a></code>, <code><a data-link-type="element" href="obsolete.html#elementdef-applet" id="ref-for-elementdef-applet-5">applet</a></code>, <code><a data-link-type="element" href="semantics-embedded-content.html#elementdef-area" id="ref-for-elementdef-area-90">area</a></code>, <code><a data-link-type="element" href="semantics-embedded-content.html#elementdef-embed" id="ref-for-elementdef-embed-39">embed</a></code>, <code><a data-link-type="element" href="sec-forms.html#elementdef-form" id="ref-for-elementdef-form-95">form</a></code>, <code><a data-link-type="element" href="obsolete.html#elementdef-frameset" id="ref-for-elementdef-frameset-8">frameset</a></code>, <code><a data-link-type="element" href="semantics-embedded-content.html#elementdef-img" id="ref-for-elementdef-img-152">img</a></code>, or <code><a data-link-type="element" href="semantics-embedded-content.html#elementdef-object" id="ref-for-elementdef-object-77">object</a></code> elements that
    have a <code>name</code> content attribute whose value is <var>name</var>, or
     </li><li><a data-link-type="dfn" href="infrastructure.html#html-element" id="ref-for-html-element-60">html elements</a> that have an <code>id</code> content attribute
    whose value is <var>name</var>.
    </li></ul>
    <div class="impl">
     <h4 class="heading settled" data-level="6.3.4" id="garbage-collection-and-browsing-contexts"><span class="secno">6.3.4. </span><span class="content">Garbage collection and browsing contexts</span><a class="self-link" href="browsers.html#garbage-collection-and-browsing-contexts"></a></h4>
     <p>A <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-170">browsing context</a> has a strong reference to each of its <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>s
  and its <code>WindowProxy</code> object, and the user agent itself has a strong reference to its <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-44">top-level browsing contexts</a>.</p>
     <p>A <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> has a strong reference to its <code>Window</code> object.</p>
     <p class="note" role="note">A <code>Window</code> object has a strong reference to its <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object through its <code>document</code> attribute. Thus, references from other scripts to either of
  those objects will keep both alive. Similarly, both <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> and <code>Window</code> objects have <a data-link-type="dfn" href="infrastructure.html#implied-strong-reference" id="ref-for-implied-strong-reference-1">implied strong references</a> to the <code>WindowProxy</code> object. </p>
     <p>Each <a data-link-type="dfn" href="webappapis.html#concept-script" id="ref-for-concept-script-5">script</a> has a strong reference to its <a data-link-type="dfn" href="webappapis.html#settings-object" id="ref-for-settings-object-2">settings
  object</a>, and each <a data-link-type="dfn" href="webappapis.html#environment-settings-object" id="ref-for-environment-settings-object-13">environment settings object</a> has strong references to its <a data-link-type="dfn" href="webappapis.html#global-object" id="ref-for-global-object-2">global object</a>, <a data-link-type="dfn" href="webappapis.html#responsible-browsing-context" id="ref-for-responsible-browsing-context-5">responsible browsing context</a>, and <a data-link-type="dfn" href="webappapis.html#responsible-document" id="ref-for-responsible-document-3">responsible
  document</a> (if any).</p>
     <p>When a <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-171">browsing context</a> is to <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="discard the document|discard a document" data-noexport="" id="discard-the-document">discard a <code>Document</code></dfn>, the user
  agent must run the following steps:</p>
     <ol>
      <li>Set the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <i>salvageable</i> state to false.
      </li><li>Run any <a data-link-type="dfn" href="browsers.html#unloading-document-cleanup-steps" id="ref-for-unloading-document-cleanup-steps-1">unloading document cleanup steps</a> for the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> that
    are defined by this specification and <a data-link-type="dfn" href="infrastructure.html#applicable-specification" id="ref-for-applicable-specification-4">other applicable specifications</a>.
      </li><li><a data-link-type="dfn" href="browsers.html#abort-the-document" id="ref-for-abort-the-document-3">Abort the <code>Document</code></a>.
      </li><li>Remove any <a data-link-type="dfn" href="webappapis.html#tasks" id="ref-for-tasks-67">tasks</a> associated with the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> in any <a data-link-type="dfn" href="webappapis.html#task-source" id="ref-for-task-source-16">task source</a>, without running those tasks.
      </li><li><a data-link-type="dfn" href="browsers.html#a-browsing-context-is-discarded" id="ref-for-a-browsing-context-is-discarded-4">Discard</a> all the <a data-link-type="dfn" href="browsers.html#child-browsing-context" id="ref-for-child-browsing-context-21">child browsing contexts</a> of the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>.
      </li><li>Lose the strong reference from the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-172">browsing context</a> to the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>.
     </li></ol>
     <p class="note" role="note"> Whenever a <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object is <a data-link-type="dfn" href="browsers.html#a-browsing-context-is-discarded" id="ref-for-a-browsing-context-is-discarded-5">discarded</a>, it is also removed from the list of the worker’s <code>Documents</code> of each worker whose list contains that <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>. </p>
     <p>When <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="a browsing context is discarded|discard|discarded" data-noexport="" id="a-browsing-context-is-discarded">a <em>browsing context</em> is discarded</dfn>, the strong reference from the user
  agent itself to the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-173">browsing context</a> must be severed, and all the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> objects for all the entries in the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-174">browsing context</a>’s session
  history must be <a data-link-type="dfn" href="browsers.html#a-browsing-context-is-discarded" id="ref-for-a-browsing-context-is-discarded-6">discarded</a> as well.</p>
     <p>User agents may <a data-link-type="dfn" href="browsers.html#a-browsing-context-is-discarded" id="ref-for-a-browsing-context-is-discarded-7">discard</a> <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-45">top-level browsing contexts</a> at any time (typically, in
  response to user requests, e.g., when a user force-closes a window containing one or more <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-46">top-level browsing contexts</a>). Other <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-175">browsing contexts</a> must be discarded once their <code>WindowProxy</code> object is eligible for garbage collection.</p>
    </div>
    <h4 class="heading settled" data-level="6.3.5" id="closing-browsing-contexts"><span class="secno">6.3.5. </span><span class="content">Closing browsing contexts</span><a class="self-link" href="browsers.html#closing-browsing-contexts"></a></h4>
    <p>When the user agent is required to <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="close-a-browsing-context">close a browsing context</dfn>, it must run the
  following steps:</p>
    <ol>
     <li>Let <var>specified browsing context</var> be the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-176">browsing context</a> being closed.
     </li><li><a data-link-type="dfn" href="browsers.html#prompt-to-unload" id="ref-for-prompt-to-unload-1">Prompt to unload</a> the <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-60">active
    document</a> of the <var>specified browsing context</var>. If the user <a data-link-type="dfn" href="browsers.html#refused-to-allow-the-document-to-be-unloaded" id="ref-for-refused-to-allow-the-document-to-be-unloaded-1">refused
    to allow the document to be unloaded</a>, then abort these steps.
     </li><li><a data-link-type="dfn" href="browsers.html#unloaded" id="ref-for-unloaded-3">Unload</a> the <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-61">active document</a> of the <var>specified browsing context</var> with the <var>recycle</var> parameter set to
    false.
     </li><li>Remove the <var>specified browsing context</var> from the user interface (e.g.,
    close or hide its tab in a tabbed browser).
     </li><li><a data-link-type="dfn" href="browsers.html#a-browsing-context-is-discarded" id="ref-for-a-browsing-context-is-discarded-8">Discard</a> the <var>specified
    browsing context</var>.
    </li></ol>
    <p>User agents should offer users the ability to arbitrarily <a data-link-type="dfn" href="browsers.html#close-a-browsing-context" id="ref-for-close-a-browsing-context-2">close</a> any <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-47">top-level browsing context</a>.</p>
    <h4 class="heading settled" data-level="6.3.6" id="browser-interface-elements"><span class="secno">6.3.6. </span><span class="content">Browser interface elements</span><a class="self-link" href="browsers.html#browser-interface-elements"></a></h4>
    <p>To allow Web pages to integrate with Web browsers, certain Web browser interface elements are
  exposed in a limited way to scripts in Web pages.</p>
    <p>Each interface element is represented by a <code>BarProp</code> object:</p>
<pre class="idl highlight def" data-highlight="webidl"><span class="kt">interface</span> <dfn class="nv dfn-paneled idl-code" data-dfn-for="BarProp" data-dfn-type="interface" data-export="" id="barprop-barprop">BarProp</dfn> {
  <span class="kt">readonly</span> <span class="kt">attribute</span> <span class="kt">boolean</span> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="boolean" href="browsers.html#dom-barprop-visible" id="ref-for-dom-barprop-visible-1">visible</a>;
};
</pre>
    <dl class="domintro">
     <dt><var>window</var> . <code>locationbar</code> . <code>visible</code>
     </dt><dd> Returns true if the location bar is visible; otherwise, returns false. 
     </dd><dt><var>window</var> . <code>menubar</code> . <code>visible</code>
     </dt><dd> Returns true if the menu bar is visible; otherwise, returns false. 
     </dd><dt><var>window</var> . <code>personalbar</code> . <code>visible</code>
     </dt><dd> Returns true if the personal bar is visible; otherwise, returns false. 
     </dd><dt><var>window</var> . <code>scrollbars</code> . <code>visible</code>
     </dt><dd> Returns true if the scroll bars are visible; otherwise, returns false. 
     </dd><dt><var>window</var> . <code>statusbar</code> . <code>visible</code>
     </dt><dd> Returns true if the status bar is visible; otherwise, returns false. 
     </dd><dt><var>window</var> . <code>toolbar</code> . <code>visible</code>
     </dt><dd> Returns true if the toolbar is visible; otherwise, returns false. 
    </dd></dl>
    <div class="impl">
     <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="BarProp" data-dfn-type="attribute" data-export="" id="dom-barprop-visible">visible</dfn> attribute, on getting, must return either
  true or a value determined by the user agent to most accurately represent the visibility state of
  the user interface element that the object represents, as described below.</p>
     <p>The following <code>BarProp</code> objects exist for each <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object in a <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-177">browsing context</a>. Some of the user interface elements represented by these objects
  might have no equivalent in some user agents; for those user agents, except when otherwise
  specified, the object must act as if it was present and visible (i.e., its <code>visible</code> attribute must return true).</p>
     <dl>
      <dt><dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="the-location-bar-barprop-object">The location bar <code>BarProp</code> object</dfn>
      </dt><dd>Represents the user interface element that contains a control that displays the <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a> of the <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-62">active document</a>, or some similar interface concept.
      </dd><dt><dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="the-menu-bar-barprop-object">The menu bar <code>BarProp</code> object</dfn>
      </dt><dd>Represents the user interface element that contains a list of commands in menu form, or some
    similar interface concept.
      </dd><dt><dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="the-personal-bar-barprop-object">The personal bar <code>BarProp</code> object</dfn>
      </dt><dd>Represents the user interface element that contains links to the user’s favorite pages, or
    some similar interface concept.
      </dd><dt><dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="the-scrollbar-barprop-object">The scrollbar <code>BarProp</code> object</dfn>
      </dt><dd>Represents the user interface element that contains a scrolling mechanism, or some similar
    interface concept.
      </dd><dt><dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="the-status-bar-barprop-object">The status bar <code>BarProp</code> object</dfn>
      </dt><dd>Represents a user interface element found immediately below or after the document, as
    appropriate for the user’s media, which typically provides information about ongoing network
    activity or information about elements that the user’s pointing device is current indicating. If
    the user agent has no such user interface element, then the object may act as if the
    corresponding user interface element was absent (i.e., its <code>visible</code> attribute may return false).
      </dd><dt><dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="the-toolbar-barprop-object">The toolbar <code>BarProp</code> object</dfn>
      </dt><dd>Represents the user interface element found immediately above or before the document, as
    appropriate for the user’s media, which typically provides <a data-link-type="dfn" href="browsers.html#session-history" id="ref-for-session-history-7">session history</a> traversal
    controls (back and forward buttons, reload buttons, etc). If the user agent has no such user
    interface element, then the object may act as if the corresponding user interface element was
    absent (i.e., its <code>visible</code> attribute may return
    false).
     </dd></dl>
     <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="Window" data-dfn-type="attribute" data-export="" id="dom-window-locationbar"><code>locationbar</code></dfn> attribute must return <a data-link-type="dfn" href="browsers.html#the-location-bar-barprop-object" id="ref-for-the-location-bar-barprop-object-1">the location bar <code>BarProp</code> object</a>.</p>
     <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="Window" data-dfn-type="attribute" data-export="" id="dom-window-menubar"><code>menubar</code></dfn> attribute must return <a data-link-type="dfn" href="browsers.html#the-menu-bar-barprop-object" id="ref-for-the-menu-bar-barprop-object-1">the
  menu bar <code>BarProp</code> object</a>.</p>
     <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="Window" data-dfn-type="attribute" data-export="" id="dom-window-personalbar"><code>personalbar</code></dfn> attribute must return <a data-link-type="dfn" href="browsers.html#the-personal-bar-barprop-object" id="ref-for-the-personal-bar-barprop-object-1">the personal bar <code>BarProp</code> object</a>.</p>
     <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="Window" data-dfn-type="attribute" data-export="" id="dom-window-scrollbars"><code>scrollbars</code></dfn> attribute must return <a data-link-type="dfn" href="browsers.html#the-scrollbar-barprop-object" id="ref-for-the-scrollbar-barprop-object-1">the scrollbar <code>BarProp</code> object</a>.</p>
     <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="Window" data-dfn-type="attribute" data-export="" id="dom-window-statusbar"><code>statusbar</code></dfn> attribute must return <a data-link-type="dfn" href="browsers.html#the-status-bar-barprop-object" id="ref-for-the-status-bar-barprop-object-1">the status bar <code>BarProp</code> object</a>.</p>
     <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="Window" data-dfn-type="attribute" data-export="" id="dom-window-toolbar"><code>toolbar</code></dfn> attribute must return <a data-link-type="dfn" href="browsers.html#the-toolbar-barprop-object" id="ref-for-the-toolbar-barprop-object-1">the
  toolbar <code>BarProp</code> object</a>.</p>
     <hr>
     <p>For historical reasons, the <dfn class="dfn-paneled idl-code" data-dfn-for="Window" data-dfn-type="attribute" data-export="" id="dom-window-status"><code>status</code></dfn> attribute
  on the <code>Window</code> object must, on getting, return the last string it was set to, and on
  setting, must set itself to the new value. When the <code>Window</code> object is created, the
  attribute must be set to the empty string. It does not do anything else.</p>
    </div>
    <h4 class="heading settled" data-level="6.3.7" id="the-windowproxy-object"><span class="secno">6.3.7. </span><span class="content">The <code>WindowProxy</code> object</span><a class="self-link" href="browsers.html#the-windowproxy-object"></a></h4>
    <p>A <dfn class="dfn-paneled idl-code" data-dfn-type="interface" data-export="" id="windowproxy"><code>WindowProxy</code></dfn> is an exotic object that wraps a <code class="idl"><a data-link-type="idl" href="browsers.html#window-window" id="ref-for-window-window-29">Window</a></code> ordinary object, indirecting most operations through to the wrapped object. Each <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-178">browsing context</a> has an associated <code class="idl"><a data-link-type="idl" href="browsers.html#windowproxy" id="ref-for-windowproxy-21">WindowProxy</a></code> object. When the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-179">browsing context</a> is <a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-45">navigated</a>, the <code class="idl"><a data-link-type="idl" href="browsers.html#window-window" id="ref-for-window-window-30">Window</a></code> object wrapped by the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-180">browsing context</a>’s associated <code class="idl"><a data-link-type="idl" href="browsers.html#windowproxy" id="ref-for-windowproxy-22">WindowProxy</a></code> object is changed.</p>
    <p>There is no <code class="idl"><a data-link-type="idl" href="browsers.html#windowproxy" id="ref-for-windowproxy-23">WindowProxy</a></code> interface object.</p>
    <p>Every <code class="idl"><a data-link-type="idl" href="browsers.html#windowproxy" id="ref-for-windowproxy-24">WindowProxy</a></code> object has a [[<dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="window slot" data-noexport="" id="window-slot">Window</dfn>]] internal slot
  representing the wrapped <code class="idl"><a data-link-type="idl" href="browsers.html#window-window" id="ref-for-window-window-31">Window</a></code> object.</p>
    <p class="note" role="note">Although <code class="idl"><a data-link-type="idl" href="browsers.html#windowproxy" id="ref-for-windowproxy-25">WindowProxy</a></code> is named as a "proxy", it does not do polymorphic
  dispatch on its target’s internal methods as a real proxy would, due to a desire to reuse
  machinery between <code class="idl"><a data-link-type="idl" href="browsers.html#windowproxy" id="ref-for-windowproxy-26">WindowProxy</a></code> and <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-9">Location</a></code> objects. As long as the <code class="idl"><a data-link-type="idl" href="browsers.html#window-window" id="ref-for-window-window-32">Window</a></code> object
  remains an ordinary object this is unobservable and can be implemented either way.</p>
    <div class="example" id="example-02e7d1b9">
     <a class="self-link" href="browsers.html#example-02e7d1b9"></a> In the following example, the variable <var>x</var> is set to the <code class="idl"><a data-link-type="idl" href="browsers.html#windowproxy" id="ref-for-windowproxy-27">WindowProxy</a></code> object
    returned by the <code class="idl"><a data-link-type="idl" href="browsers.html#dom-window-window" id="ref-for-dom-window-window-2">window</a></code> accessor on the <a data-link-type="dfn" href="webappapis.html#global-object" id="ref-for-global-object-3">global object</a>. All of the
    expressions following the assignment return true, because the <code class="idl"><a data-link-type="idl" href="browsers.html#windowproxy" id="ref-for-windowproxy-28">WindowProxy</a></code> object passes
    most operations through to the underlying ordinary <code class="idl"><a data-link-type="idl" href="browsers.html#window-window" id="ref-for-window-window-33">Window</a></code> object. 
<pre class="highlight"><span class="kd">var</span> <span class="nx">x</span> <span class="o">=</span> <span class="nb">window</span><span class="p">;</span>
<span class="nx">x</span> <span class="k">instanceof</span> <span class="nx">Window</span><span class="p">;</span> <span class="c1">// true</span>
<span class="nx">x</span> <span class="o">===</span> <span class="k">this</span><span class="p">;</span> <span class="c1">// true</span>
</pre>
    </div>
    <h5 class="heading settled" data-level="6.3.7.1" id="windowproxy-internal-methods"><span class="secno">6.3.7.1. </span><span class="content">The <code>WindowProxy</code> internal methods</span><a class="self-link" href="browsers.html#windowproxy-internal-methods"></a></h5>
    <p>The <code class="idl"><a data-link-type="idl" href="browsers.html#windowproxy" id="ref-for-windowproxy-29">WindowProxy</a></code> object internal methods are described in the subsections below.</p>
    <h6 class="heading settled" data-level="6.3.7.1.1" id="windowproxy-getprototypeof-algorithm"><span class="secno">6.3.7.1.1. </span><span class="content">[[<dfn data-dfn-type="dfn" data-lt="windowproxy getprototypeof" data-noexport="" id="windowproxy-getprototypeof">GetPrototypeOf<a class="self-link" href="browsers.html#windowproxy-getprototypeof"></a></dfn>]] ( )</span><a class="self-link" href="browsers.html#windowproxy-getprototypeof-algorithm"></a></h6>
    <ol>
     <li data-md="">
      <p>Let <var>W</var> be the value of the [[<a data-link-type="dfn" href="browsers.html#window-slot" id="ref-for-window-slot-1">Window</a>]] internal slot of <em>this</em>.</p>
     </li><li data-md="">
      <p>If <a data-link-type="dfn" href="browsers.html#isplatformobjectsameorigin" id="ref-for-isplatformobjectsameorigin-2">IsPlatformObjectSameOrigin</a>(<var>W</var>) is true, then return ! <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-ordinarygetprototypeof">OrdinaryGetPrototypeOf</a>(<var>W</var>).</p>
     </li><li data-md="">
      <p>Return null.</p>
    </li></ol>
    <h6 class="heading settled" data-level="6.3.7.1.2" id="windowproxy-setprototypeof-algorithm"><span class="secno">6.3.7.1.2. </span><span class="content">[[<dfn data-dfn-type="dfn" data-lt="windowproxy setprototypeof" data-noexport="" id="windowproxy-setprototypeof">SetPrototypeOf<a class="self-link" href="browsers.html#windowproxy-setprototypeof"></a></dfn>]] ( V )</span><a class="self-link" href="browsers.html#windowproxy-setprototypeof-algorithm"></a></h6>
    <ol>
     <li data-md="">
      <p>Return false.</p>
    </li></ol>
    <h6 class="heading settled" data-level="6.3.7.1.3" id="windowproxy-isextensible-algorithm"><span class="secno">6.3.7.1.3. </span><span class="content">[[<dfn data-dfn-type="dfn" data-lt="windowproxy isextensible" data-noexport="" id="windowproxy-isextensible">IsExtensible<a class="self-link" href="browsers.html#windowproxy-isextensible"></a></dfn>]] ( )</span><a class="self-link" href="browsers.html#windowproxy-isextensible-algorithm"></a></h6>
    <ol>
     <li data-md="">
      <p>Return true.</p>
    </li></ol>
    <h6 class="heading settled" data-level="6.3.7.1.4" id="windowproxy-preventextensions-algorithm"><span class="secno">6.3.7.1.4. </span><span class="content">[[<dfn data-dfn-type="dfn" data-lt="windowproxy preventextensions" data-noexport="" id="windowproxy-preventextensions">PreventExtensions<a class="self-link" href="browsers.html#windowproxy-preventextensions"></a></dfn>]] ( )</span><a class="self-link" href="browsers.html#windowproxy-preventextensions-algorithm"></a></h6>
    <ol>
     <li data-md="">
      <p>Return false.</p>
    </li></ol>
    <h6 class="heading settled" data-level="6.3.7.1.5" id="windowproxy-getownproperty-algorithm"><span class="secno">6.3.7.1.5. </span><span class="content">[[<dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="windowproxy getownproperty" data-noexport="" id="windowproxy-getownproperty">GetOwnProperty</dfn>]] ( <var>P</var> )</span><a class="self-link" href="browsers.html#windowproxy-getownproperty-algorithm"></a></h6>
    <ol>
     <li data-md="">
      <p>Let <var>W</var> be the value of the [[<a data-link-type="dfn" href="browsers.html#window-slot" id="ref-for-window-slot-2">Window</a>]] internal slot of <em>this</em>.</p>
     </li><li data-md="">
      <p>If <var>P</var> is an <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-array-index-property-name">array index property name</a>, then:</p>
      <ol>
       <li data-md="">
        <p>Let <var>index</var> be <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-touint32">ToUint32</a>(<var>P</var>).</p>
       </li><li data-md="">
        <p>Let <var>maxProperties</var> be the <a data-link-type="dfn" href="browsers.html#number-of-child-browsing-contexts" id="ref-for-number-of-child-browsing-contexts-3">number of child browsing contexts</a> of <var>W</var>.</p>
       </li><li data-md="">
        <p>Let <var>value</var> be undefined.</p>
       </li><li data-md="">
        <p>If <var>maxProperties</var> is greater than 0 and <var>index</var> is less than <var>maxProperties</var>, then:</p>
        <ol>
         <li data-md="">
          <p>Set <var>value</var> to the <code class="idl"><a data-link-type="idl" href="browsers.html#windowproxy" id="ref-for-windowproxy-30">WindowProxy</a></code> object of the <var>index</var>th <a data-link-type="dfn" href="browsers.html#child-browsing-context" id="ref-for-child-browsing-context-22">child browsing context</a> of the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> that is <a data-link-type="dfn" href="browsers.html#through-which-new-document-is-nested" id="ref-for-through-which-new-document-is-nested-4">nested through</a> an element that is in <var>W</var>’s <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>, sorted in the
  order that the elements nesting those <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-181">browsing contexts</a> were most recently
  inserted into the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>, the <code class="idl"><a data-link-type="idl" href="browsers.html#windowproxy" id="ref-for-windowproxy-31">WindowProxy</a></code> object of the most recently
  inserted <a data-link-type="dfn" href="browsers.html#browsing-context-container" id="ref-for-browsing-context-container-28">browsing context container</a>’s <a data-link-type="dfn" href="browsers.html#nested-browsing-contexts" id="ref-for-nested-browsing-contexts-64">nested browsing context</a> being
  last.</p>
        </li></ol>
       </li><li data-md="">
        <p>Return <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-property-descriptor-specification-type">PropertyDescriptor</a>{ [[Value]]: <var>value</var>, [[Writable]]: false,
  [[Enumerable]]: false, [[Configurable]]: true }.</p>
      </li></ol>
     </li><li data-md="">
      <p>If <a data-link-type="dfn" href="browsers.html#isplatformobjectsameorigin" id="ref-for-isplatformobjectsameorigin-3">IsPlatformObjectSameOrigin</a>(<var>W</var>) is true, then return <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-ordinarygetownproperty">OrdinaryGetOwnProperty</a>(<var>W</var>, <var>P</var>).</p>
      <p class="note" role="note">This violates JavaScript’s internal method invariants.</p>
     </li><li data-md="">
      <p>Let <var>property</var> be <a data-link-type="dfn" href="browsers.html#crossorigingetownpropertyhelper" id="ref-for-crossorigingetownpropertyhelper-2">CrossOriginGetOwnPropertyHelper</a>(<var>W</var>, <var>P</var>).</p>
     </li><li data-md="">
      <p>If <var>property</var> is not undefined, return <var>property</var>.</p>
     </li><li data-md="">
      <p>If <var>property</var> is undefined and <var>P</var> is in the <a data-link-type="dfn" href="browsers.html#child-browsing-context-name-property-set" id="ref-for-child-browsing-context-name-property-set-3">child browsing context name property set</a>, then:</p>
      <ol>
       <li data-md="">
        <p>Let <var>value</var> be the <code class="idl"><a data-link-type="idl" href="browsers.html#windowproxy" id="ref-for-windowproxy-32">WindowProxy</a></code> object of the <a data-link-type="dfn" href="browsers.html#named-objects" id="ref-for-named-objects-3">named object</a> with the name <var>P</var>.</p>
       </li><li data-md="">
        <p>Return <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-property-descriptor-specification-type">PropertyDescriptor</a>{ [[Value]]: <var>value</var>, [[Enumerable]]: false,
  [[Writable]]: false, [[Configurable]]: true }.</p>
      </li></ol>
     </li><li data-md="">
      <p>Throw a "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#securityerror">SecurityError</a></code>" <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/WebIDL-1/#idl-DOMException">DOMException</a></code>.</p>
    </li></ol>
    <h6 class="heading settled" data-level="6.3.7.1.6" id="windowproxy-defineownproperty-algorithm"><span class="secno">6.3.7.1.6. </span><span class="content">[[<dfn data-dfn-type="dfn" data-lt="windowproxy defineownproperty" data-noexport="" id="windowproxy-defineownproperty">DefineOwnProperty<a class="self-link" href="browsers.html#windowproxy-defineownproperty"></a></dfn>]] ( <var>P</var>, <var>Desc</var> )</span><a class="self-link" href="browsers.html#windowproxy-defineownproperty-algorithm"></a></h6>
    <ol>
     <li data-md="">
      <p>If <var>P</var> is an <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-array-index-property-name">array index property name</a>, return false.</p>
     </li><li data-md="">
      <p>Let <var>W</var> be the value of the [[<a data-link-type="dfn" href="browsers.html#window-slot" id="ref-for-window-slot-3">Window</a>]] internal slot of <em>this</em>.</p>
     </li><li data-md="">
      <p>If <a data-link-type="dfn" href="browsers.html#isplatformobjectsameorigin" id="ref-for-isplatformobjectsameorigin-4">IsPlatformObjectSameOrigin</a>(<var>W</var>) is true, then return <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-ordinarydefineownproperty">OrdinaryDefineOwnProperty</a>(<var>W</var>, <var>P</var>, <var>Desc</var>).</p>
      <p class="note" role="note">See above about how this violates JavaScript’s internal method invariants.</p>
     </li><li data-md="">
      <p>Return false.</p>
    </li></ol>
    <h6 class="heading settled" data-level="6.3.7.1.7" id="windowproxy-get-algorithm"><span class="secno">6.3.7.1.7. </span><span class="content">[[<dfn data-dfn-type="dfn" data-lt="windowproxy get" data-noexport="" id="windowproxy-get">Get<a class="self-link" href="browsers.html#windowproxy-get"></a></dfn>]] ( <var>P</var>, <var>Receiver</var> )</span><a class="self-link" href="browsers.html#windowproxy-get-algorithm"></a></h6>
    <ol>
     <li data-md="">
      <p>Let <var>W</var> be the value of the [[<a data-link-type="dfn" href="browsers.html#window-slot" id="ref-for-window-slot-4">Window</a>]] internal slot of <em>this</em>.</p>
     </li><li data-md="">
      <p>If <a data-link-type="dfn" href="browsers.html#isplatformobjectsameorigin" id="ref-for-isplatformobjectsameorigin-5">IsPlatformObjectSameOrigin</a>(<var>W</var>) is true, then return <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-ordinaryget">OrdinaryGet</a>(this, <var>P</var>, <var>Receiver</var>).</p>
     </li><li data-md="">
      <p>Return ? <a data-link-type="dfn" href="browsers.html#crossoriginget" id="ref-for-crossoriginget-1">CrossOriginGet</a>(this, <var>P</var>, <var>Receiver</var>).</p>
    </li></ol>
    <h6 class="heading settled" data-level="6.3.7.1.8" id="windowproxy-set-algorithm"><span class="secno">6.3.7.1.8. </span><span class="content">[[<dfn data-dfn-type="dfn" data-lt="windowproxy set" data-noexport="" id="windowproxy-set">Set<a class="self-link" href="browsers.html#windowproxy-set"></a></dfn>]] ( <var>P</var>, V, <var>Receiver</var> )</span><a class="self-link" href="browsers.html#windowproxy-set-algorithm"></a></h6>
    <ol>
     <li data-md="">
      <p>Let <var>W</var> be the value of the [[<a data-link-type="dfn" href="browsers.html#window-slot" id="ref-for-window-slot-5">Window</a>]] internal slot of <em>this</em>.</p>
     </li><li data-md="">
      <p>If <a data-link-type="dfn" href="browsers.html#isplatformobjectsameorigin" id="ref-for-isplatformobjectsameorigin-6">IsPlatformObjectSameOrigin</a>(<var>W</var>) is true, then return <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-ordinaryset">OrdinarySet</a>(<var>W</var>, this, <var>Receiver</var>).</p>
     </li><li data-md="">
      <p>Return <a data-link-type="dfn" href="browsers.html#crossoriginset" id="ref-for-crossoriginset-1">CrossOriginSet</a>(this, <var>P</var>, V, <var>Receiver</var>).</p>
    </li></ol>
    <h6 class="heading settled" data-level="6.3.7.1.9" id="windowproxy-delete-algorithm"><span class="secno">6.3.7.1.9. </span><span class="content">[[<dfn data-dfn-type="dfn" data-lt="windowproxy delete" data-noexport="" id="windowproxy-delete">Delete<a class="self-link" href="browsers.html#windowproxy-delete"></a></dfn>]] ( <var>P</var> )</span><a class="self-link" href="browsers.html#windowproxy-delete-algorithm"></a></h6>
    <ol>
     <li data-md="">
      <p>If <var>P</var> is an <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-array-index-property-name">array index property name</a>, return false.</p>
     </li><li data-md="">
      <p>Let <var>W</var> be the value of the [[<a data-link-type="dfn" href="browsers.html#window-slot" id="ref-for-window-slot-6">Window</a>]] internal slot of <em>this</em>.</p>
     </li><li data-md="">
      <p>If <a data-link-type="dfn" href="browsers.html#isplatformobjectsameorigin" id="ref-for-isplatformobjectsameorigin-7">IsPlatformObjectSameOrigin</a>(<var>W</var>) is true, then return <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-ordinarydelete">OrdinaryDelete</a>(<var>W</var>, <var>P</var>).</p>
     </li><li data-md="">
      <p>Return false.</p>
    </li></ol>
    <h6 class="heading settled" data-level="6.3.7.1.10" id="windowproxy-ownpropertykeys-algorithm"><span class="secno">6.3.7.1.10. </span><span class="content">[[<dfn data-dfn-type="dfn" data-lt="windowproxy ownpropertykeys" data-noexport="" id="windowproxy-ownpropertykeys">OwnPropertyKeys<a class="self-link" href="browsers.html#windowproxy-ownpropertykeys"></a></dfn>]] ( )</span><a class="self-link" href="browsers.html#windowproxy-ownpropertykeys-algorithm"></a></h6>
    <ol>
     <li data-md="">
      <p>Let <var>W</var> be the value of the [[<a data-link-type="dfn" href="browsers.html#window-slot" id="ref-for-window-slot-7">Window</a>]] internal slot of <em>this</em>.</p>
     </li><li data-md="">
      <p>Let <var>keys</var> be a new empty <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-list-and-record-specification-type">List</a>.</p>
     </li><li data-md="">
      <p>Let <var>maxProperties</var> be the <a data-link-type="dfn" href="browsers.html#number-of-child-browsing-contexts" id="ref-for-number-of-child-browsing-contexts-4">number of child browsing contexts</a> of <var>W</var>.</p>
     </li><li data-md="">
      <p>Let <var>index</var> be 0.</p>
     </li><li data-md="">
      <p>Repeat while <var>index</var> &lt; <var>maxProperties</var>,</p>
      <ol>
       <li data-md="">
        <p>Add ! <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-tostring">ToString</a>(<var>index</var>) as the last element of <var>keys</var>.</p>
       </li><li data-md="">
        <p>Increment <var>index</var> by 1.</p>
      </li></ol>
     </li><li data-md="">
      <p>If <a data-link-type="dfn" href="browsers.html#isplatformobjectsameorigin" id="ref-for-isplatformobjectsameorigin-8">IsPlatformObjectSameOrigin</a>(<var>W</var>) is true, then return the concatenation of <var>keys</var> and ! OrdinaryOwnPropertyKeys(<var>W</var>).</p>
     </li><li data-md="">
      <p>Return the concatenation of <var>keys</var> and ! <a data-link-type="dfn" href="browsers.html#crossoriginownpropertykeys" id="ref-for-crossoriginownpropertykeys-1">CrossOriginOwnPropertyKeys</a>(<var>W</var>).</p>
    </li></ol>
    <h3 class="heading settled" data-level="6.4" id="section-origin"><span class="secno">6.4. </span><span class="content">Origin</span><a class="self-link" href="browsers.html#section-origin"></a></h3>
    <p>Origins are the fundamental currency of the Web’s security model. Two actors in the Web
  platform that share an origin are assumed to trust each other and to have the same authority.
  Actors with differing origins are considered potentially hostile versus each other, and are
  isolated from each other to varying degrees.</p>
    <p class="example" id="example-22455137"><a class="self-link" href="browsers.html#example-22455137"></a>For example, if Example Bank’s Web site, hosted at <code>bank.example.com</code>, tries to examine the DOM of Example Charity’s Web site, hosted at <code>charity.example.org</code>, a "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#securityerror">SecurityError</a></code>" <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/WebIDL-1/#idl-DOMException">DOMException</a></code> will be raised. </p>
    <hr>
    <p>An <dfn class="dfn-paneled" data-dfn-for="concept" data-dfn-type="dfn" data-lt="cross-origin|origin|origins" data-noexport="" id="concept-cross-origin">origin</dfn> is one of the following:</p>
    <dl>
     <dt data-md="">
      <p>An <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="opaque-origin">opaque origin</dfn></p>
     </dt><dd data-md="">
      <p>An internal value, with no serialisation, for which the only meaningful operation is testing
  for equality.</p>
     </dd><dt data-md="">
      <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="tuple origin|tuple" data-noexport="" id="tuple-origin">tuple origin</dfn></p>
     </dt><dd data-md="">
      <p>A <a data-link-type="dfn" href="browsers.html#tuple-origin" id="ref-for-tuple-origin-1">tuple</a> consists of:</p>
      <ul>
       <li data-md="">
        <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="origin scheme" data-noexport="" id="origin-scheme">scheme</dfn> (a <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-scheme">scheme</a>).</p>
       </li><li data-md="">
        <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="origin host" data-noexport="" id="origin-host">host</dfn> (a <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-host">host</a>).</p>
       </li><li data-md="">
        <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="origin port" data-noexport="" id="origin-port">port</dfn> (a <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-port">port</a>).</p>
       </li><li data-md="">
        <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="origin domain" data-noexport="" id="origin-domain">domain</dfn> (null or a <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-domain">domain</a>). Null unless
  stated otherwise.</p>
      </li></ul>
    </dd></dl>
    <p class="note" role="note">Origins can be shared, e.g., among multiple <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> objects. Furthermore, <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-46">origins</a> are generally immutable. Only the <a data-link-type="dfn" href="browsers.html#origin-domain" id="ref-for-origin-domain-1">domain</a> of a <a data-link-type="dfn" href="browsers.html#tuple-origin" id="ref-for-tuple-origin-2">tuple origin</a> can be changed, and only through the <code class="idl"><a data-link-type="idl" href="browsers.html#dom-document-domain" id="ref-for-dom-document-domain-6">document.domain</a></code> API. </p>
    <p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="effective-domain">effective domain</dfn> of an <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-47">origin</a> <var>origin</var> is computed as
  follows:</p>
    <ol>
     <li data-md="">
      <p>If <var>origin</var> is an <a data-link-type="dfn" href="browsers.html#opaque-origin" id="ref-for-opaque-origin-4">opaque origin</a>, then return <var>origin</var>.</p>
     </li><li data-md="">
      <p>If <var>origin</var>’s <a data-link-type="dfn" href="browsers.html#origin-domain" id="ref-for-origin-domain-2">domain</a> is non-null, then return <var>origin</var>’s <a data-link-type="dfn" href="browsers.html#origin-domain" id="ref-for-origin-domain-3">domain</a>.</p>
     </li><li data-md="">
      <p>Return <var>origin</var>’s <a data-link-type="dfn" href="browsers.html#origin-host" id="ref-for-origin-host-1">host</a>.</p>
    </li></ol>
    <p>Various specification objects are defined to have an <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-48">origin</a>. These <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-49">origins</a> are determined as follows:</p>
    <dl>
     <dt data-md="">
      <p>For <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> objects</p>
     </dt><dd data-md="">
      <dl class="switch">
       <dt><dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="forces content into a unique origin" data-noexport="" id="forces-content-into-a-unique-origin"></dfn>If the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <a data-link-type="dfn" href="browsers.html#active-sandboxing-flag-set" id="ref-for-active-sandboxing-flag-set-13">active sandboxing flag set</a> has its <a data-link-type="dfn" href="browsers.html#sandboxed-into-a-unique-origin" id="ref-for-sandboxed-into-a-unique-origin-2">sandboxed origin browsing context flag</a> set
       </dt><dd>A unique <a data-link-type="dfn" href="browsers.html#opaque-origin" id="ref-for-opaque-origin-5">opaque origin</a> is assigned when the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> is created.
       </dd><dt>If the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-scheme">scheme</a> is a <a data-link-type="dfn" href="https://url.spec.whatwg.org/#network-scheme">network scheme</a>
       </dt><dd>
        A copy of the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-origin">origin</a> assigned
    when the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> is created. 
        <p class="note" role="note">The <code class="idl"><a data-link-type="idl" href="webappapis.html#dom-document-_open" id="ref-for-dom-document-_open-4">document.open()</a></code> method can change the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a> to "<code>about:blank</code>". Therefore the <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-50">origin</a> is assigned when the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> is created.</p>
       </dd><dt>If the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> is the initial "<code>about:blank</code>" document
       </dt><dd><a data-link-type="dfn" href="browsers.html#creating-a-new-browsing-context" id="ref-for-creating-a-new-browsing-context-1">The one it was assigned when its browsing context
    was created</a>.
       </dd><dt>If the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> is a non-initial "<code>about:blank</code>" document
       </dt><dt>If the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> was generated from a <a data-link-type="scheme" href="infrastructure.html#schemedef-data-url" id="ref-for-schemedef-data-url-9"><code>data:</code> URL</a> found in another <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> or in a script
       </dt><dd>The <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-51">origin</a> of the <a data-link-type="dfn" href="webappapis.html#incumbent-settings-object" id="ref-for-incumbent-settings-object-5">incumbent settings object</a> when the <a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-46">navigate</a> algorithm was invoked, or, if no <a data-link-type="dfn" href="webappapis.html#concept-script" id="ref-for-concept-script-6">script</a> was involved,
    of the <a data-link-type="dfn" href="https://www.w3.org/TR/dom/#concept-node-document">node document</a> of the element that initiated the <a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-47">navigation</a> to that <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a>.
       </dd><dt>If the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> was created as part of the processing for <a data-link-type="dfn" href="browsers.html#javascript-urls" id="ref-for-javascript-urls-1"><code>javascript:</code> URLs</a>
       </dt><dd>The <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-52">origin</a> of the <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-63">active document</a> of the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-182">browsing context</a> being navigated when the <a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-48">navigate</a> algorithm was invoked.
       </dd><dt>If the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> is <a data-link-type="dfn" href="semantics-embedded-content.html#iframe-iframe-srcdoc-document" id="ref-for-iframe-iframe-srcdoc-document-10">an <code>iframe</code> <code>srcdoc</code> document</a>
       </dt><dd>The <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-53">origin</a> of the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-183">browsing context</a>’s <a data-link-type="dfn" href="browsers.html#browsing-context-container" id="ref-for-browsing-context-container-29">browsing context container</a>’s <a data-link-type="dfn" href="https://www.w3.org/TR/dom/#concept-node-document">node document</a>.
       </dd><dt>If the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> was obtained in some other manner (e.g., a <a data-link-type="scheme" href="infrastructure.html#schemedef-data-url" id="ref-for-schemedef-data-url-10"><code>data:</code> URL</a> typed in by the user or that was returned as
    the location of a redirect, a <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> created using the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#dom-domimplementation-createdocument">createDocument()</a></code> API, etc)
       </dt><dd>
        The default behavior as defined in the DOM standard applies. <a data-link-type="biblio" href="references.html#biblio-dom">[DOM]</a>. 
        <p class="note" role="note">The <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-54">origin</a> is a unique <a data-link-type="dfn" href="browsers.html#opaque-origin" id="ref-for-opaque-origin-6">opaque origin</a> assigned
    when the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> is created.</p>
      </dd></dl>
     </dd><dt data-md="">
      <p>For images of <code><a data-link-type="element" href="semantics-embedded-content.html#elementdef-img" id="ref-for-elementdef-img-153">img</a></code> elements</p>
     </dt><dd data-md="">
      <dl class="switch">
       <dt>If the image data is <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-cors-check">CORS-cross-origin</a>
       </dt><dd>A unique <a data-link-type="dfn" href="browsers.html#opaque-origin" id="ref-for-opaque-origin-7">opaque origin</a> assigned when the image is created.
       </dd><dt>If the image data is <a data-link-type="dfn" href="browsers.html#same-origin" id="ref-for-same-origin-15">CORS-same-origin</a>
       </dt><dd>The <code><a data-link-type="element" href="semantics-embedded-content.html#elementdef-img" id="ref-for-elementdef-img-154">img</a></code> element’s <a data-link-type="dfn" href="https://www.w3.org/TR/dom/#concept-node-document">node document</a>’s <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-55">origin</a>.
      </dd></dl>
     </dd><dt data-md="">
      <p>For <code><a data-link-type="element" href="semantics-embedded-content.html#elementdef-audio" id="ref-for-elementdef-audio-25">audio</a></code> and <code><a data-link-type="element" href="semantics-embedded-content.html#elementdef-video" id="ref-for-elementdef-video-49">video</a></code> elements</p>
     </dt><dd data-md="">
      <dl class="switch">
       <dt>If the <a data-link-type="dfn" href="semantics-embedded-content.html#media-data" id="ref-for-media-data-39">media data</a> is <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-cors-check">CORS-cross-origin</a>
       </dt><dd>A unique <a data-link-type="dfn" href="browsers.html#opaque-origin" id="ref-for-opaque-origin-8">opaque origin</a> assigned when the <a data-link-type="dfn" href="semantics-embedded-content.html#media-data" id="ref-for-media-data-40">media data</a> is fetched.
       </dd><dt>If the <a data-link-type="dfn" href="semantics-embedded-content.html#media-data" id="ref-for-media-data-41">media data</a> is <a data-link-type="dfn" href="browsers.html#same-origin" id="ref-for-same-origin-16">CORS-same-origin</a>
       </dt><dd>The <a data-link-type="dfn" href="semantics-embedded-content.html#media-element" id="ref-for-media-element-253">media element</a>’s <a data-link-type="dfn" href="https://www.w3.org/TR/dom/#concept-node-document">node document</a>’s <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-56">origin</a>. 
      </dd></dl>
     </dd><dt data-md="">
      <p>For fonts</p>
     </dt><dd data-md="">
      <p>For a downloadable Web font it is a copy of the <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-origin">origin</a> of the <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url">URL record</a> used to obtain the font (after any redirects). <a data-link-type="biblio" href="references.html#biblio-css-fonts-3">[CSS-FONTS-3]</a> <a data-link-type="biblio" href="references.html#biblio-css-font-loading-3">[CSS-FONT-LOADING-3]</a></p>
      <p>For a locally installed system font it is the <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-57">origin</a> of the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> in which that font is being used.</p>
    </dd></dl>
    <p>Other specifications can override the above definitions by themselves specifying the origin of
  a particular <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object, image, <a data-link-type="dfn" href="semantics-embedded-content.html#media-element" id="ref-for-media-element-254">media element</a>, or font.</p>
    <hr>
    <p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="unicode serialization|unicode serialization of an origin" data-noexport="" id="unicode-serialization">Unicode serialization of an origin</dfn> is the string obtained by applying the following algorithm to the given <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-58">origin</a> <var>origin</var>:</p>
    <ol>
     <li data-md="">
      <p>If <var>origin</var> is an <a data-link-type="dfn" href="browsers.html#opaque-origin" id="ref-for-opaque-origin-9">opaque origin</a>, then return "<code>null</code>".</p>
     </li><li data-md="">
      <p>Let <var>host</var> be <var>origin</var>’s <a data-link-type="dfn" href="browsers.html#origin-host" id="ref-for-origin-host-2">host</a>.</p>
     </li><li data-md="">
      <p>Let <var>unicodeHost</var> be <var>host</var> if <var>host</var> is not a <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-domain">domain</a>, and the result of applying <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-domain-to-unicode">domain to Unicode</a> to <var>host</var> otherwise.</p>
     </li><li data-md="">
      <p>Let <var>unicodeOrigin</var> be a new <a data-link-type="dfn" href="browsers.html#tuple-origin" id="ref-for-tuple-origin-3">tuple origin</a> consisting <var>origin</var>’s <a data-link-type="dfn" href="browsers.html#origin-scheme" id="ref-for-origin-scheme-1">scheme</a>, <var>unicodeHost</var>, and <var>origin</var>’s <a data-link-type="dfn" href="browsers.html#origin-port" id="ref-for-origin-port-1">port</a>.</p>
     </li><li data-md="">
      <p>Return the <a data-link-type="dfn" href="browsers.html#ascii-serialization-of-an-origin" id="ref-for-ascii-serialization-of-an-origin-1">ASCII serialization of an origin</a>, given <var>unicodeOrigin</var>.</p>
      <p class="note" role="note">The name <a data-link-type="dfn" href="browsers.html#ascii-serialization-of-an-origin" id="ref-for-ascii-serialization-of-an-origin-2">ASCII serialization of an origin</a> is misleading, as it merely
  serialises an origin, which are all ASCII by default due to the <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-parser">URL parser</a>.</p>
    </li></ol>
    <div class="example" id="example-b511c450"><a class="self-link" href="browsers.html#example-b511c450"></a> The <a data-link-type="dfn" href="browsers.html#unicode-serialization" id="ref-for-unicode-serialization-2">Unicode serialization</a> of ("<code>https</code>", "<code>xn--maraa-rta.example</code>",
  null, null) is "<code>https://maraña.example</code>". </div>
    <p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="ascii-serialization-of-an-origin">ASCII serialization of an origin</dfn> is the string obtained by applying the
  following algorithm to the given <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-59">origin</a> <var>origin</var>:</p>
    <ol>
     <li data-md="">
      <p>If <var>origin</var> is an <a data-link-type="dfn" href="browsers.html#opaque-origin" id="ref-for-opaque-origin-10">opaque origin</a>, then return "<code>null</code>".</p>
     </li><li data-md="">
      <p>Otherwise, let <var>result</var> be <var>origin</var>’s <a data-link-type="dfn" href="browsers.html#origin-scheme" id="ref-for-origin-scheme-2">scheme</a>.</p>
     </li><li data-md="">
      <p>Append "<code>://</code>" to <var>result</var>.</p>
     </li><li data-md="">
      <p>Append <var>origin</var>’s <a data-link-type="dfn" href="browsers.html#origin-host" id="ref-for-origin-host-3">host</a>, <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-serializer">serialized</a>, to <var>result</var>.</p>
     </li><li data-md="">
      <p>If <var>origin</var>’s <a data-link-type="dfn" href="browsers.html#origin-port" id="ref-for-origin-port-2">port</a> is non-null, append a
  U+003A COLON character (:), and <var>origin</var>’s <a data-link-type="dfn" href="browsers.html#origin-port" id="ref-for-origin-port-3">port</a>, <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-serializer">serialized</a>, to <var>result</var>.</p>
     </li><li data-md="">
      <p>Return <var>result</var>.</p>
    </li></ol>
    <p>Two <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-60">origins</a> <var>A</var> and <var>B</var> are said to be <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="same origin|comparing origins|cors-same-origin" data-noexport="" id="same-origin">same origin</dfn> if the following
  algorithm returns true:</p>
    <ol>
     <li data-md="">
      <p>If <var>A</var> and <var>B</var> are the same <a data-link-type="dfn" href="browsers.html#opaque-origin" id="ref-for-opaque-origin-11">opaque origin</a>, then return true.</p>
     </li><li data-md="">
      <p>If <var>A</var> and <var>B</var> are both <a data-link-type="dfn" href="browsers.html#tuple-origin" id="ref-for-tuple-origin-4">tuple origins</a>, and their <a data-link-type="dfn" href="browsers.html#origin-scheme" id="ref-for-origin-scheme-3">schemes</a>, <a data-link-type="dfn" href="browsers.html#origin-host" id="ref-for-origin-host-4">hosts</a>, and <a data-link-type="dfn" href="browsers.html#origin-port" id="ref-for-origin-port-4">ports</a> are identical, then return true.</p>
     </li><li data-md="">
      <p>Return false.</p>
    </li></ol>
    <p>Two <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-61">origins</a> <var>A</var> and <var>B</var> are said to be <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="same-origin-domain">same origin-domain</dfn> if the following algorithm returns true:</p>
    <ol>
     <li data-md="">
      <p>If <var>A</var> and <var>B</var> are the same <a data-link-type="dfn" href="browsers.html#opaque-origin" id="ref-for-opaque-origin-12">opaque origin</a>, then return true.</p>
     </li><li data-md="">
      <p>If <var>A</var> and <var>B</var> are both <a data-link-type="dfn" href="browsers.html#tuple-origin" id="ref-for-tuple-origin-5">tuple origins</a>, run these substeps:</p>
      <ol>
       <li data-md="">
        <p>If <var>A</var> and <var>B</var>’s <a data-link-type="dfn" href="browsers.html#origin-scheme" id="ref-for-origin-scheme-4">schemes</a> are identical, and
  their <a data-link-type="dfn" href="browsers.html#origin-domain" id="ref-for-origin-domain-4">domains</a> are identical and non-null, then return true.</p>
       </li><li data-md="">
        <p>Otherwise, if <var>A</var> and <var>B</var> are <a data-link-type="dfn" href="browsers.html#same-origin" id="ref-for-same-origin-17">same origin</a> and their <a data-link-type="dfn" href="browsers.html#origin-domain" id="ref-for-origin-domain-5">domains</a> are identical and null, then return true.</p>
      </li></ol>
     </li><li data-md="">
      <p>Return false.</p>
    </li></ol>
    <div class="example" id="example-80bf1994">
     <a class="self-link" href="browsers.html#example-80bf1994"></a> The following table shows how <var>A</var> and <var>B</var> are related: 
     <table>
      <thead>
       <tr>
        <th>A 
        </th><th>B 
        </th><th><a data-link-type="dfn" href="browsers.html#same-origin" id="ref-for-same-origin-18">same origin</a> 
        </th><th><a data-link-type="dfn" href="browsers.html#same-origin-domain" id="ref-for-same-origin-domain-6">same origin-domain</a> 
      </th></tr></thead><tbody>
       <tr>
        <td>("<code>https</code>", "<code>example.org</code>", null, null) 
        </td><td>("<code>https</code>", "<code>example.org</code>", null, null) 
        </td><td>✅ 
        </td><td>✅ 
       </td></tr><tr>
        <td>("<code>https</code>", "<code>example.org</code>", 314, "<code>example.org</code>") 
        </td><td>("<code>https</code>", "<code>example.org</code>", 420, "<code>example.org</code>") 
        </td><td>❌ 
        </td><td>✅ 
       </td></tr><tr>
        <td>("<code>https</code>", "<code>example.org</code>", null, null) 
        </td><td>("<code>https</code>", "<code>example.org</code>", null, "<code>example.org</code>") 
        </td><td>✅ 
        </td><td>❌ 
       </td></tr><tr>
        <td>("<code>https</code>", "<code>example.org</code>", null, "<code>example.org</code>") 
        </td><td>("http", "<code>example.org</code>", null, "<code>example.org</code>") 
        </td><td>❌ 
        </td><td>❌ 
     </td></tr></tbody></table>
    </div>
    <h4 class="heading settled" data-level="6.4.1" id="relaxing-the-same-origin-restriction"><span class="secno">6.4.1. </span><span class="content">Relaxing the same-origin restriction</span><a class="self-link" href="browsers.html#relaxing-the-same-origin-restriction"></a></h4>
    <dl class="domintro">
     <dt><var>document</var> . <code class="idl"><a data-link-type="idl" href="browsers.html#dom-document-domain" id="ref-for-dom-document-domain-7">domain</a></code> [ = <var>domain</var> ]
     </dt><dd>
      Returns the current domain used for security checks. 
      <p>Can be set to a value that removes subdomains, to change the <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-62">origin</a>’s <a data-link-type="dfn" href="browsers.html#origin-domain" id="ref-for-origin-domain-6">domain</a> to allow pages on other subdomains of the same domain (if they
    do the same thing) to access each other. (Can’t be set in sandboxed <code><a data-link-type="element" href="semantics-embedded-content.html#elementdef-iframe" id="ref-for-elementdef-iframe-57">iframe</a></code>s.)</p>
    </dd></dl>
    <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="Document" data-dfn-type="attribute" data-export="" id="dom-document-domain"><code>domain</code></dfn> attribute’s getter must run these
  steps:</p>
    <ol>
     <li data-md="">
      <p>If this <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object does not have a <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-184">browsing context</a>, then return the empty
  string.</p>
     </li><li data-md="">
      <p>Let <var>effectiveDomain</var> be this <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-63">origin</a>’s <a data-link-type="dfn" href="browsers.html#effective-domain" id="ref-for-effective-domain-3">effective domain</a>.</p>
     </li><li data-md="">
      <p>If <var>effectiveDomain</var> is an <a data-link-type="dfn" href="browsers.html#opaque-origin" id="ref-for-opaque-origin-13">opaque origin</a>, then return the empty string.</p>
     </li><li data-md="">
      <p>Return <var>effectiveDomain</var>, <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-host-serializer">serialised</a>.</p>
    </li></ol>
    <p>The <code class="idl"><a data-link-type="idl" href="browsers.html#dom-document-domain" id="ref-for-dom-document-domain-8">domain</a></code> attribute on setting must run these steps:</p>
    <ol>
     <li data-md="">
      <p>If this <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object has no <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-185">browsing context</a>, throw a
  "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#securityerror">SecurityError</a></code>" <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/WebIDL-1/#idl-DOMException">DOMException</a></code>.</p>
     </li><li data-md="">
      <p>If this <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object’s <a data-link-type="dfn" href="browsers.html#active-sandboxing-flag-set" id="ref-for-active-sandboxing-flag-set-14">active sandboxing flag set</a> has its <a data-link-type="dfn" href="browsers.html#sandboxed-documentdomain-browsing-context-flag" id="ref-for-sandboxed-documentdomain-browsing-context-flag-1">sandboxed <code>document.domain</code> browsing context flag</a> set, then throw a
  "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#securityerror">SecurityError</a></code>" <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/WebIDL-1/#idl-DOMException">DOMException</a></code>.</p>
     </li><li data-md="">
      <p>If the given value is the empty string, then throw a "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#securityerror">SecurityError</a></code>" <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/WebIDL-1/#idl-DOMException">DOMException</a></code>.</p>
     </li><li data-md="">
      <p>Let <var>host</var> be the result of <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-host-parser">parsing</a> the given value.</p>
     </li><li data-md="">
      <p>If <var>host</var> is failure, then throw a "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#securityerror">SecurityError</a></code>" <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/WebIDL-1/#idl-DOMException">DOMException</a></code>.</p>
     </li><li data-md="">
      <p>Let <var>effectiveDomain</var> be this <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object’s <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-64">origin</a>’s <a data-link-type="dfn" href="browsers.html#effective-domain" id="ref-for-effective-domain-4">effective domain</a>.</p>
     </li><li data-md="">
      <p>If <var>host</var> is not <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-host-equals">equal</a> to <var>effectiveDomain</var>, then run
  these substeps:</p>
      <ol>
       <li data-md="">
        <p>If <var>host</var> or <var>effectiveDomain</var> is not <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-domain">domain</a>, then throw
  a "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#securityerror">SecurityError</a></code>" <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/WebIDL-1/#idl-DOMException">DOMException</a></code>.</p>
        <p class="note" role="note">This is meant to exclude <a data-link-type="dfn" href="browsers.html#origin-host" id="ref-for-origin-host-5">hosts</a> that are an <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-ipv4">IPv4 address</a> or an <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-ipv6">IPv6 address</a>. </p>
       </li><li data-md="">
        <p>If <var>host</var>, prefixed by a U+002E FULL STOP (.), does not exactly match
  the <var>effectiveDomain</var>, then throw a "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#securityerror">SecurityError</a></code>" <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/WebIDL-1/#idl-DOMException">DOMException</a></code>.</p>
       </li><li data-md="">
        <p>If <var>host</var> matches a suffix in the Public Suffix List, or, if <var>host</var>,
  prefixed by a U+002E FULL STOP (.), matches the end of a suffix in the Public Suffix List,
  then throw a "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#securityerror">SecurityError</a></code>" <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/WebIDL-1/#idl-DOMException">DOMException</a></code>. <a data-link-type="biblio" href="references.html#biblio-psl">[PSL]</a></p>
        <p>Suffixes must be compared after applying the <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-host-parser">host parser</a> algorithm. <a data-link-type="biblio" href="references.html#biblio-url">[URL]</a></p>
      </li></ol>
     </li><li data-md="">
      <p>Set <var>origin</var>’s <a data-link-type="dfn" href="browsers.html#origin-domain" id="ref-for-origin-domain-7">domain</a> to <var>host</var>.</p>
    </li></ol>
    <p class="note" role="note">The <code class="idl"><a data-link-type="idl" href="browsers.html#dom-document-domain" id="ref-for-dom-document-domain-9">document.domain</a></code> attribute is used to enable pages on
  different hosts of a domain to access each others' DOMs.</p>
    <p class="warning">Do not use the <code class="idl"><a data-link-type="idl" href="browsers.html#dom-document-domain" id="ref-for-dom-document-domain-10">document.domain</a></code> attribute when using shared
  hosting. If an untrusted third party is able to host an HTTP server at the same IP address but on
  a different port, then the same-origin protection that normally protects two different sites on
  the same host will fail, as the ports are ignored when comparing origins after the <code class="idl"><a data-link-type="idl" href="browsers.html#dom-document-domain" id="ref-for-dom-document-domain-11">document.domain</a></code> attribute has been used.</p>
    <h3 class="heading settled" data-level="6.5" id="sandboxing"><span class="secno">6.5. </span><span class="content">Sandboxing</span><a class="self-link" href="browsers.html#sandboxing"></a></h3>
    <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="sandboxing-flag-set">sandboxing flag set</dfn> is a set of zero or more of the following flags, which are
  used to restrict the abilities that potentially untrusted resources have:</p>
    <dl>
     <dt>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="sandboxed-navigation-browsing-context-flag">sandboxed navigation browsing context flag</dfn>
     </dt><dd>
      <p>This flag <a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-49">prevents content from navigating browsing contexts other
    than the sandboxed browsing context itself</a> (or browsing contexts further nested inside it), <a data-link-type="dfn" href="browsers.html#auxiliary-browsing-contexts" id="ref-for-auxiliary-browsing-contexts-9">auxiliary browsing contexts</a> (which are protected
    by the <a data-link-type="dfn" href="browsers.html#sandboxed-auxiliary-navigation-browsing-context-flag" id="ref-for-sandboxed-auxiliary-navigation-browsing-context-flag-2">sandboxed auxiliary navigation browsing context flag</a> defined next), and the <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-48">top-level browsing context</a> (which is protected by the <a data-link-type="dfn" href="browsers.html#sandboxed-top-level-navigation-browsing-context-flag" id="ref-for-sandboxed-top-level-navigation-browsing-context-flag-2">sandboxed top-level
    navigation browsing context flag</a> defined below).</p>
      <p>If the <a data-link-type="dfn" href="browsers.html#sandboxed-auxiliary-navigation-browsing-context-flag" id="ref-for-sandboxed-auxiliary-navigation-browsing-context-flag-3">sandboxed auxiliary navigation browsing context flag</a> is not set, then in
    certain cases the restrictions nonetheless allow popups (new <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-49">top-level browsing contexts</a>) to be opened. These <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-186">browsing contexts</a> always have <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="one-permitted-sandboxed-navigator">one permitted sandboxed navigator</dfn>, set
    when the browsing context is created, which allows the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-187">browsing context</a> that
    created them to actually navigate them. (Otherwise, the <a data-link-type="dfn" href="browsers.html#sandboxed-navigation-browsing-context-flag" id="ref-for-sandboxed-navigation-browsing-context-flag-4">sandboxed navigation browsing
    context flag</a> would prevent them from being navigated even if they were opened.)</p>
     </dd><dt>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="sandboxed-auxiliary-navigation-browsing-context-flag">sandboxed auxiliary navigation browsing context flag</dfn>
     </dt><dd>
      <p>This flag <a data-link-type="dfn" href="browsers.html#prevents-content-from-creating-new-auxiliary-browsing-contexts" id="ref-for-prevents-content-from-creating-new-auxiliary-browsing-contexts-1">prevents content from creating new auxiliary browsing
    contexts</a>, e.g., using the <code>target</code> attribute, the <code>window.open()</code> method, or the <code>showModalDialog()</code> method.</p>
     </dd><dt>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="sandboxed-top-level-navigation-browsing-context-flag">sandboxed top-level navigation browsing context flag</dfn>
     </dt><dd>
      <p>This flag <a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-50">prevents content from navigating their top-level
    browsing context</a> and <a class="idl-code" data-link-type="method" href="browsers.html#dom-window-close" id="ref-for-dom-window-close-2">prevents content from closing their
    top-level browsing context</a>.</p>
      <p>When the <a data-link-type="dfn" href="browsers.html#sandboxed-top-level-navigation-browsing-context-flag" id="ref-for-sandboxed-top-level-navigation-browsing-context-flag-3">sandboxed top-level navigation browsing context flag</a> is <em>not</em> set, content can navigate its <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-50">top-level browsing context</a>, but other <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-188">browsing contexts</a> are still protected by the <a data-link-type="dfn" href="browsers.html#sandboxed-navigation-browsing-context-flag" id="ref-for-sandboxed-navigation-browsing-context-flag-5">sandboxed
    navigation browsing context flag</a> and possibly the <a data-link-type="dfn" href="browsers.html#sandboxed-auxiliary-navigation-browsing-context-flag" id="ref-for-sandboxed-auxiliary-navigation-browsing-context-flag-4">sandboxed auxiliary navigation
    browsing context flag</a>.</p>
     </dd><dt>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="sandboxed-plugins-browsing-context-flag">sandboxed plugins browsing context flag</dfn>
     </dt><dd>
      <p>This flag prevents content from instantiating <a data-link-type="dfn" href="infrastructure.html#plugin" id="ref-for-plugin-58">plugins</a>, whether
    using <span>the <code><a data-link-type="element" href="semantics-embedded-content.html#elementdef-embed" id="ref-for-elementdef-embed-40">embed</a></code> element</span>, <span>the <code><a data-link-type="element" href="semantics-embedded-content.html#elementdef-object" id="ref-for-elementdef-object-78">object</a></code> element</span>, <span>the <code><a data-link-type="element" href="obsolete.html#elementdef-applet" id="ref-for-elementdef-applet-6">applet</a></code> element</span>, or through <a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-51">navigation</a> of a <a data-link-type="dfn" href="browsers.html#nested-browsing-contexts" id="ref-for-nested-browsing-contexts-65">nested browsing context</a>, unless
    those <a data-link-type="dfn" href="infrastructure.html#plugin" id="ref-for-plugin-59">plugins</a> can be <a data-link-type="dfn" href="infrastructure.html#secured" id="ref-for-secured-6">secured</a>.</p>
     </dd><dt>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="sandboxed into a unique origin|sandboxed origin browsing context flag" data-noexport="" id="sandboxed-into-a-unique-origin">sandboxed origin browsing context flag</dfn>
     </dt><dd>
      <p>This flag <a data-link-type="dfn" href="browsers.html#forces-content-into-a-unique-origin" id="ref-for-forces-content-into-a-unique-origin-1">forces content into a unique origin</a>, thus preventing
    it from accessing other content from the same <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-65">origin</a>.</p>
      <p>This flag also <a data-link-type="dfn" href="dom.html#cookie-averse" id="ref-for-cookie-averse-3">prevents script from reading from or writing to the <code>document.cookie</code> IDL attribute</a>, and blocks access to <code>localStorage</code>. <a data-link-type="biblio" href="references.html#biblio-webstorage">[WEBSTORAGE]</a></p>
     </dd><dt>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="sandboxed-forms-browsing-context-flag">sandboxed forms browsing context flag</dfn>
     </dt><dd>
      <p>This flag <a data-link-type="dfn" href="sec-forms.html#submit" id="ref-for-submit-9">blocks form submission</a>.</p>
     </dd><dt>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="sandboxed-pointer-lock-browsing-context-flag">sandboxed pointer lock browsing context flag</dfn>
     </dt><dd>
      <p>This flag disables the Pointer Lock API. <a data-link-type="biblio" href="references.html#biblio-pointerlock">[POINTERLOCK]</a></p>
     </dd><dt>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="sandboxed-scripts-browsing-context-flag">sandboxed scripts browsing context flag</dfn>
     </dt><dd>
      <p>This flag <a data-link-type="dfn" href="webappapis.html#scripting-was-enabled" id="ref-for-scripting-was-enabled-7">blocks script execution</a>.</p>
     </dd><dt>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="sandboxed-automatic-features-browsing-context-flag">sandboxed automatic features browsing context flag</dfn>
     </dt><dd>
      <p>This flag blocks features that trigger automatically, such as <a data-link-type="element-attr" href="semantics-embedded-content.html#element-attrdef-media-autoplay" id="ref-for-element-attrdef-media-autoplay-1">automatically playing a video</a> or <a data-link-type="element-attr" href="sec-forms.html#element-attrdef-formelements-autofocus" id="ref-for-element-attrdef-formelements-autofocus-18">automatically focusing a form control</a>.</p>
     </dd><dt>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="sandboxed-storage-area-urls-flag">sandboxed storage area URLs flag</dfn>
     </dt><dd>
      <p>This flag prevents URL schemes that use storage areas from being able to access the origin’s
    data.</p>
     </dd><dt>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="sandboxed-fullscreen-browsing-context-flag">sandboxed fullscreen browsing context flag</dfn>
     </dt><dd>
      <p>This flag prevents content from using the <code>requestFullscreen()</code> method.</p>
     </dd><dt>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="sandboxed-documentdomain-browsing-context-flag">sandboxed <code>document.domain</code> browsing context flag</dfn>
     </dt><dd>This flag prevents content from using the <code class="idl"><a data-link-type="idl" href="browsers.html#dom-document-domain" id="ref-for-dom-document-domain-12">document.domain</a></code> setter.
     </dd><dt>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="sandbox-propagates-to-auxiliary-browsing-contexts-flag">sandbox propagates to auxiliary browsing contexts flag</dfn>
     </dt><dd>
      <p>This flag prevents content from escaping the sandbox by ensuring that any <a data-link-type="dfn" href="browsers.html#auxiliary-browsing-contexts" id="ref-for-auxiliary-browsing-contexts-10">auxiliary browsing context</a> it creates inherits the content’s <a data-link-type="dfn" href="browsers.html#active-sandboxing-flag-set" id="ref-for-active-sandboxing-flag-set-15">active sandboxing flag set</a>.</p>
     </dd><dt>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="sandboxed-modals-flag">sandboxed modals flag</dfn>
     </dt><dd>
      <p>This flag prevents content from using any of the following features to produce modal
    dialogs:</p>
      <ul>
       <li><code>window.alert()</code>
       </li><li><code>window.confirm()</code>
       </li><li><code>window.print()</code>
       </li><li><code>window.prompt()</code>
       </li><li><code>window.showModalDialog()</code>
       </li><li>the <code>beforeunload</code> event
      </li></ul>
    </dd></dl>
    <p>When the user agent is to <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="parse the sandboxing directive|parse a sandboxing directive" data-noexport="" id="parse-the-sandboxing-directive">parse a sandboxing directive</dfn>, given a string <var>input</var>, a <a data-link-type="dfn" href="browsers.html#sandboxing-flag-set" id="ref-for-sandboxing-flag-set-1">sandboxing flag set</a> <var>output</var>, and
  optionally an <var>allow fullscreen flag</var>, it must run the following steps:</p>
    <ol>
     <li><a data-link-type="dfn" href="infrastructure.html#split-a-string-on-spaces" id="ref-for-split-a-string-on-spaces-10">Split <var>input</var> on spaces</a>,
    to obtain <var>tokens</var>.
     </li><li>Let <var>output</var> be empty.
     </li><li>
      <p>Add the following flags to <var>output</var>:</p>
      <ul>
       <li>The <a data-link-type="dfn" href="browsers.html#sandboxed-navigation-browsing-context-flag" id="ref-for-sandboxed-navigation-browsing-context-flag-6">sandboxed navigation browsing context flag</a>.
       </li><li>The <a data-link-type="dfn" href="browsers.html#sandboxed-auxiliary-navigation-browsing-context-flag" id="ref-for-sandboxed-auxiliary-navigation-browsing-context-flag-5">sandboxed auxiliary navigation browsing context flag</a>, unless <var>tokens</var> contains the <dfn data-dfn-type="dfn" data-noexport="" id="allow-popups"><code>allow-popups</code><a class="self-link" href="browsers.html#allow-popups"></a></dfn> keyword.
       </li><li>The <a data-link-type="dfn" href="browsers.html#sandboxed-top-level-navigation-browsing-context-flag" id="ref-for-sandboxed-top-level-navigation-browsing-context-flag-4">sandboxed top-level navigation browsing context flag</a>, unless <var>tokens</var> contains the <dfn data-dfn-type="dfn" data-noexport="" id="allow-top-navigation"><code>allow-top-navigation</code><a class="self-link" href="browsers.html#allow-top-navigation"></a></dfn> keyword.
       </li><li>The <a data-link-type="dfn" href="browsers.html#sandboxed-plugins-browsing-context-flag" id="ref-for-sandboxed-plugins-browsing-context-flag-3">sandboxed plugins browsing context flag</a>.
       </li><li>
        <p>The <a data-link-type="dfn" href="browsers.html#sandboxed-into-a-unique-origin" id="ref-for-sandboxed-into-a-unique-origin-3">sandboxed origin browsing context flag</a>, unless the <var>tokens</var> contains the <dfn data-dfn-type="dfn" data-noexport="" id="allow-same-origin"><code>allow-same-origin</code><a class="self-link" href="browsers.html#allow-same-origin"></a></dfn> keyword.</p>
        <div class="note" role="note">
         <p>The <code>allow-same-origin</code> keyword
        is intended for two cases.</p>
         <p>First, it can be used to allow content from the same site to be sandboxed to disable
        scripting, while still allowing access to the DOM of the sandboxed content.</p>
         <p>Second, it can be used to embed content from a third-party site, sandboxed to prevent that
        site from opening pop-up windows, etc, without preventing the embedded page from
        communicating back to its originating site, using the database APIs to store data, etc.</p>
        </div>
       </li><li>The <a data-link-type="dfn" href="browsers.html#sandboxed-forms-browsing-context-flag" id="ref-for-sandboxed-forms-browsing-context-flag-2">sandboxed forms browsing context flag</a>, unless <var>tokens</var> contains the <dfn data-dfn-type="dfn" data-noexport="" id="allow-forms"><code>allow-forms</code><a class="self-link" href="browsers.html#allow-forms"></a></dfn> keyword.
       </li><li>The <a data-link-type="dfn" href="browsers.html#sandboxed-pointer-lock-browsing-context-flag" id="ref-for-sandboxed-pointer-lock-browsing-context-flag-1">sandboxed pointer lock browsing context flag</a>, unless <var>tokens</var> contains the <dfn data-dfn-type="dfn" data-noexport="" id="allow-pointer-lock"><code>allow-pointer-lock</code><a class="self-link" href="browsers.html#allow-pointer-lock"></a></dfn> keyword.
       </li><li>The <a data-link-type="dfn" href="browsers.html#sandboxed-scripts-browsing-context-flag" id="ref-for-sandboxed-scripts-browsing-context-flag-1">sandboxed scripts browsing context flag</a>, unless <var>tokens</var> contains the <dfn data-dfn-type="dfn" data-noexport="" id="allow-scripts"><code>allow-scripts</code><a class="self-link" href="browsers.html#allow-scripts"></a></dfn> keyword.
       </li><li>
        <p>The <a data-link-type="dfn" href="browsers.html#sandboxed-automatic-features-browsing-context-flag" id="ref-for-sandboxed-automatic-features-browsing-context-flag-4">sandboxed automatic features browsing context flag</a>, unless <var>tokens</var> contains the <code>allow-scripts</code> keyword (defined above).</p>
        <p class="note" role="note"> This flag is relaxed by the same keyword as scripts, because when scripts are
      enabled these features are trivially possible anyway, and it would be unfortunate to force
      authors to use script to do them when sandboxed rather than allowing them to use the
      declarative features. </p>
       </li><li>The <a data-link-type="dfn" href="browsers.html#sandboxed-storage-area-urls-flag" id="ref-for-sandboxed-storage-area-urls-flag-1">sandboxed storage area URLs flag</a>.
       </li><li>The <a data-link-type="dfn" href="browsers.html#sandboxed-fullscreen-browsing-context-flag" id="ref-for-sandboxed-fullscreen-browsing-context-flag-1">sandboxed fullscreen browsing context flag</a>, unless the <var>allow fullscreen flag</var> was passed to the <a data-link-type="dfn" href="browsers.html#parse-the-sandboxing-directive" id="ref-for-parse-the-sandboxing-directive-2">parse a sandboxing
      directive</a> flag.
       </li><li>The <a data-link-type="dfn" href="browsers.html#sandboxed-documentdomain-browsing-context-flag" id="ref-for-sandboxed-documentdomain-browsing-context-flag-2">sandboxed <code>document.domain</code> browsing
      context flag</a>.
       </li><li>The <a data-link-type="dfn" href="browsers.html#sandbox-propagates-to-auxiliary-browsing-contexts-flag" id="ref-for-sandbox-propagates-to-auxiliary-browsing-contexts-flag-2">sandbox propagates to auxiliary browsing contexts flag</a>, unless <var>tokens</var> contains the <dfn data-dfn-type="dfn" data-noexport="" id="allow-popups-to-escape-sandbox"><code>allow-popups-to-escape-sandbox</code><a class="self-link" href="browsers.html#allow-popups-to-escape-sandbox"></a></dfn> keyword.
       </li><li>The <a data-link-type="dfn" href="browsers.html#sandboxed-modals-flag" id="ref-for-sandboxed-modals-flag-1">sandboxed modals flag</a>, unless <var>tokens</var> contains the <dfn data-dfn-type="dfn" data-noexport="" id="allow-modals"><code>allow-modals</code><a class="self-link" href="browsers.html#allow-modals"></a></dfn> keyword.
      </li></ul>
    </li></ol>
    <hr>
    <p>Every <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-51">top-level browsing context</a> has a <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="popup-sandboxing-flag-set">popup sandboxing flag set</dfn>, which
  is a <a data-link-type="dfn" href="browsers.html#sandboxing-flag-set" id="ref-for-sandboxing-flag-set-2">sandboxing flag set</a>. When a <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-189">browsing context</a> is created, its <a data-link-type="dfn" href="browsers.html#popup-sandboxing-flag-set" id="ref-for-popup-sandboxing-flag-set-2">popup sandboxing flag set</a> must be empty. It is populated by <a data-link-type="dfn" href="browsers.html#the-rules-for-choosing-a-browsing-context-given-a-browsing-context-name" id="ref-for-the-rules-for-choosing-a-browsing-context-given-a-browsing-context-name-9">the rules for
  choosing a browsing context given a browsing context name</a>.</p>
    <p>Every <a data-link-type="dfn" href="browsers.html#nested-browsing-contexts" id="ref-for-nested-browsing-contexts-66">nested browsing context</a> has an <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="iframe sandboxing flag set" data-noexport="" id="iframe-sandboxing-flag-set"><code>iframe</code> sandboxing flag
  set</dfn>, which is a <a data-link-type="dfn" href="browsers.html#sandboxing-flag-set" id="ref-for-sandboxing-flag-set-3">sandboxing flag set</a>. Which flags in a <a data-link-type="dfn" href="browsers.html#nested-browsing-contexts" id="ref-for-nested-browsing-contexts-67">nested browsing context</a>’s <a data-link-type="dfn" href="browsers.html#iframe-sandboxing-flag-set" id="ref-for-iframe-sandboxing-flag-set-1"><code>iframe</code> sandboxing flag set</a> are set at any
  particular time is determined by the <code><a data-link-type="element" href="semantics-embedded-content.html#elementdef-iframe" id="ref-for-elementdef-iframe-58">iframe</a></code> element’s <code><a data-link-type="element-sub" href="semantics-embedded-content.html#element-attrdef-iframe-sandbox" id="ref-for-element-attrdef-iframe-sandbox-17">sandbox</a></code> attribute.</p>
    <p>Every <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> has an <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="active-sandboxing-flag-set">active sandboxing flag set</dfn>, which is a <a data-link-type="dfn" href="browsers.html#sandboxing-flag-set" id="ref-for-sandboxing-flag-set-4">sandboxing flag set</a>. When the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> is created, its <a data-link-type="dfn" href="browsers.html#active-sandboxing-flag-set" id="ref-for-active-sandboxing-flag-set-16">active
  sandboxing flag set</a> must be empty. It is populated by the <a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-52">navigation
  algorithm</a>.</p>
    <p>Every resource that is obtained by the <a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-53">navigation algorithm</a> has a <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="forced-sandboxing-flag-set">forced sandboxing flag set</dfn>, which is a <a data-link-type="dfn" href="browsers.html#sandboxing-flag-set" id="ref-for-sandboxing-flag-set-5">sandboxing flag set</a>. A resource by
  default has no flags set in its <a data-link-type="dfn" href="browsers.html#forced-sandboxing-flag-set" id="ref-for-forced-sandboxing-flag-set-1">forced sandboxing flag set</a>, but other specifications
  can define that certain flags are set.</p>
    <p class="note" role="note"> In particular, the <a data-link-type="dfn" href="browsers.html#forced-sandboxing-flag-set" id="ref-for-forced-sandboxing-flag-set-2">forced sandboxing flag set</a> is used by the Content
  Security Policy specification. <a data-link-type="biblio" href="references.html#biblio-csp3">[CSP3]</a> </p>
    <hr>
    <p>When a user agent is to <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="implement-the-sandboxing">implement the sandboxing</dfn> for a <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>, it
  must populate <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <a data-link-type="dfn" href="browsers.html#active-sandboxing-flag-set" id="ref-for-active-sandboxing-flag-set-17">active sandboxing flag set</a> with the union of
  the flags that are present in the following <a data-link-type="dfn" href="browsers.html#sandboxing-flag-set" id="ref-for-sandboxing-flag-set-6">sandboxing flag
  sets</a> at the time the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object is created:</p>
    <ul>
     <li>If the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-190">browsing context</a> is a <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-52">top-level browsing
    context</a>, then: the flags set on the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-191">browsing context</a>’s <a data-link-type="dfn" href="browsers.html#popup-sandboxing-flag-set" id="ref-for-popup-sandboxing-flag-set-3">popup sandboxing
    flag set</a>.
     </li><li>If the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-192">browsing context</a> is a <a data-link-type="dfn" href="browsers.html#nested-browsing-contexts" id="ref-for-nested-browsing-contexts-68">nested browsing context</a>, then: the flags set on the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-193">browsing context</a>’s <a data-link-type="dfn" href="browsers.html#iframe-sandboxing-flag-set" id="ref-for-iframe-sandboxing-flag-set-2"><code>iframe</code> sandboxing flag set</a>.
     </li><li>If the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-194">browsing context</a> is a <a data-link-type="dfn" href="browsers.html#nested-browsing-contexts" id="ref-for-nested-browsing-contexts-69">nested browsing context</a>, then: the flags set on the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-195">browsing context</a>’s <a data-link-type="dfn" href="browsers.html#parent-browsing-context" id="ref-for-parent-browsing-context-17">parent browsing
    context</a>’s <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-64">active document</a>’s <a data-link-type="dfn" href="browsers.html#active-sandboxing-flag-set" id="ref-for-active-sandboxing-flag-set-18">active sandboxing flag set</a>.
     </li><li>The flags set on the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s resource’s <a data-link-type="dfn" href="browsers.html#forced-sandboxing-flag-set" id="ref-for-forced-sandboxing-flag-set-3">forced sandboxing flag
    set</a>, if it has one.
    </li></ul>
    <h3 class="heading settled" data-level="6.6" id="session-history-and-navigation"><span class="secno">6.6. </span><span class="content">Session history and navigation</span><a class="self-link" href="browsers.html#session-history-and-navigation"></a></h3>
    <h4 class="heading settled" data-level="6.6.1" id="the-session-history-of-browsing-contexts"><span class="secno">6.6.1. </span><span class="content">The session history of browsing contexts</span><a class="self-link" href="browsers.html#the-session-history-of-browsing-contexts"></a></h4>
    <p>The sequence of <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>s in a <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-196">browsing context</a> is its <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="session history" data-noexport="" id="session-history">session
  history</dfn>. Each <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-197">browsing context</a>, including <a data-link-type="dfn" href="browsers.html#nested-browsing-contexts" id="ref-for-nested-browsing-contexts-70">nested browsing contexts</a>, has a distinct session history. A <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-198">browsing
  context</a>’s session history consists of a flat list of <a data-link-type="dfn" href="browsers.html#session-history-entry" id="ref-for-session-history-entry-1">session history entries</a>. Each <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="session-history-entry">session history entry</dfn> consists, at a
  minimum, of a <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a>, and each entry may in addition have a <a data-link-type="dfn" href="browsers.html#state-object" id="ref-for-state-object-1">state object</a>, a
  title, a <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object, form data, a <a data-link-type="dfn" href="browsers.html#scroll-restoration-mode" id="ref-for-scroll-restoration-mode-1">scroll restoration mode</a>, a scroll
  position, and other information associated with it.</p>
    <p class="note" role="note"> Each entry, when first created, has a <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>. However, when a <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> is not <a data-link-type="dfn" href="browsers.html#fully-active" id="ref-for-fully-active-19">active</a>, it’s possible for it to be <a data-link-type="dfn" href="browsers.html#a-browsing-context-is-discarded" id="ref-for-a-browsing-context-is-discarded-9">discarded</a> to free resources. The <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a> and
  other data in a <a data-link-type="dfn" href="browsers.html#session-history-entry" id="ref-for-session-history-entry-2">session history entry</a> is then used to bring a new <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> into being to take the place of the original, should the user agent find
  itself having to reactivate that <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>. </p>
    <p class="note" role="note"> Titles associated with <a data-link-type="dfn" href="browsers.html#session-history-entry" id="ref-for-session-history-entry-3">session history
  entries</a> need not have any relation with the current <code>title</code> of the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>. The title of a <a data-link-type="dfn" href="browsers.html#session-history-entry" id="ref-for-session-history-entry-4">session history entry</a> is intended to explain
  the state of the document at that point, so that the user can navigate the document’s history. </p>
    <p>URLs without associated <a data-link-type="dfn" href="browsers.html#state-object" id="ref-for-state-object-2">state objects</a> are added to the
  session history as the user (or script) navigates from page to page.</p>
    <hr>
    <p>Each <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object in a <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-199">browsing context</a>’s <a data-link-type="dfn" href="browsers.html#session-history" id="ref-for-session-history-8">session
  history</a> is associated with a unique <code>History</code> object which must all model the
  same underlying <a data-link-type="dfn" href="browsers.html#session-history" id="ref-for-session-history-9">session history</a>.</p>
    <div class="impl"> The <dfn class="dfn-paneled idl-code" data-dfn-for="Window" data-dfn-type="attribute" data-export="" id="dom-window-history"><code>history</code></dfn> attribute of the <code>Window</code> interface must return
    the object implementing the <code>History</code> interface for that <code class="idl"><a data-link-type="idl" href="browsers.html#window-window" id="ref-for-window-window-34">Window</a></code> object’s newest <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>. </div>
    <hr>
    <p>A <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="state-object">state object</dfn> is an object representing a user interface state.</p>
    <p>Pages can <a class="idl-code" data-link-type="method" href="browsers.html#dom-history-pushstate" id="ref-for-dom-history-pushstate-1">add</a> <a data-link-type="dfn" href="browsers.html#state-object" id="ref-for-state-object-3">state
  objects</a> to the session history. These are then <a class="idl-code" data-link-type="attribute" href="webappapis.html#dom-windoweventhandlers-onpopstate" id="ref-for-dom-windoweventhandlers-onpopstate-1">returned to the
  script</a> when the user (or script) goes back in the history, thus enabling authors to use the
  "navigation" metaphor even in one-page applications.</p>
    <div class="note" role="note">
      <a data-link-type="dfn" href="browsers.html#state-object" id="ref-for-state-object-4">State objects</a> are intended to be used for two main purposes:
    first, storing a preparsed description of the state in the <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a> so that in the simple
    case an author doesn’t have to do the parsing (though one would still need the parsing for
    handling <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URLs</a> passed around by users, so it’s only a minor
    optimization), and second, so that the author can store state that one wouldn’t store in the URL
    because it only applies to the current <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> instance and it would have to be
    reconstructed if a new <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> were opened. 
     <p>An example of the latter would be something like keeping track of the precise coordinate from
    which a pop-up <code>div</code> was made to animate, so that if the user goes back, it can be
    made to animate to the same location. Or alternatively, it could be used to keep a pointer into a
    cache of data that would be fetched from the server based on the information in the <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a>, so that when going back and forward, the information doesn’t have to be fetched
    again.</p>
    </div>
    <hr>
    <p>At any point, one of the entries in the session history is the <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="current-entry">current entry</dfn>. This
  is the entry representing the <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-65">active document</a> of the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-200">browsing context</a>.
  Which entry is the <a data-link-type="dfn" href="browsers.html#current-entry" id="ref-for-current-entry-1">current entry</a> is changed by the algorithms defined in this
  specification, e.g., during <a data-link-type="dfn" href="browsers.html#traverse-the-history" id="ref-for-traverse-the-history-2">session history traversal</a>.</p>
    <p class="note" role="note"> The <a data-link-type="dfn" href="browsers.html#current-entry" id="ref-for-current-entry-2">current entry</a> is usually an entry for the <a data-link-type="dfn" href="dom.html#the-document-address" id="ref-for-the-document-address-17">address</a> of the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>. However, it can also be one of the entries for <a data-link-type="dfn" href="browsers.html#state-object" id="ref-for-state-object-5">state objects</a> added
    to the history by that document. </p>
    <p><dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="an-entry-with-persisted-user-state">An entry with persisted user state</dfn> is one that also has user-agent defined state.
  This specification does not specify what kind of state can be stored.</p>
    <p class="example" id="example-5ffc8a54"><a class="self-link" href="browsers.html#example-5ffc8a54"></a> For example, some user agents might want to persist the scroll position, or the
  values of form controls. </p>
    <p class="note" role="note"> User agents that persist the value of form controls are encouraged to also persist
  their directionality (the value of the element’s <code>dir</code> attribute).
  This prevents values from being displayed incorrectly after a history traversal when the user had
  originally entered the values with an explicit, non-default directionality. </p>
    <p>An entry’s <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="scroll-restoration-mode">scroll restoration mode</dfn> indicates whether the user agent should restore the
  persisted scroll position (if any) when traversing to it. The scroll restoration
  mode may be one of the following:</p>
    <p></p>
    <dl>
     <dt>"<dfn class="css" data-dfn-for="scrollRestorationMode" data-dfn-type="value" data-export="" id="valdef-scrollrestorationmode-auto"><code>auto</code><a class="self-link" href="browsers.html#valdef-scrollrestorationmode-auto"></a></dfn>"
     </dt><dd>The user agent is responsible for restoring the scroll position upon navigation.
     </dd><dt>"<dfn class="css" data-dfn-for="scrollRestorationMode" data-dfn-type="value" data-export="" id="valdef-scrollrestorationmode-manual"><code>manual</code><a class="self-link" href="browsers.html#valdef-scrollrestorationmode-manual"></a></dfn>"
     </dt><dd>The page is responsible for restoring the scroll position and the user agent does not
   attempt to do so automatically
    </dd></dl>
    <p>If unspecified, the <a data-link-type="dfn" href="browsers.html#scroll-restoration-mode" id="ref-for-scroll-restoration-mode-2">scroll restoration mode</a> of a new entry must be set to
  "<code>auto</code>".</p>
    <p>Entries that consist of <a data-link-type="dfn" href="browsers.html#state-object" id="ref-for-state-object-6">state objects</a> share the same <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> as the entry for the page that was active when they were added.</p>
    <p>Contiguous entries that differ just by fragment identifier also share the same <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>.</p>
    <p class="note" role="note"> All entries that share the same <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> (and that are therefore
  merely different states of one particular document) are contiguous by definition. </p>
    <p>Each <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> in a <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-201">browsing context</a> can also have a <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="latest entry" data-noexport="" id="latest-entry">latest
  entry</dfn>. This is the entry for that <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> to which the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-202">browsing
  context</a>’s <a data-link-type="dfn" href="browsers.html#session-history" id="ref-for-session-history-10">session history</a> was most recently traversed. When a <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> is created, it initially has no <a data-link-type="dfn" href="browsers.html#latest-entry" id="ref-for-latest-entry-1">latest entry</a>.</p>
    <div class="impl">
     <p>User agents may <a data-link-type="dfn" href="browsers.html#a-browsing-context-is-discarded" id="ref-for-a-browsing-context-is-discarded-10">discard</a> the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> objects of entries other than the <a data-link-type="dfn" href="browsers.html#current-entry" id="ref-for-current-entry-3">current entry</a> that are not referenced from any
  script, reloading the pages afresh when the user or script navigates back to such pages. This
  specification does not specify when user agents should discard <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> objects and
  when they should cache them.</p>
     <p>Entries that have had their <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> objects discarded must, for the purposes of
  the algorithms given below, act as if they had not. When the user or script navigates back or
  forwards to a page which has no in-memory DOM objects, any other entries that shared the same <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object with it must share the new object as well.</p>
    </div>
    <h4 class="heading settled" data-level="6.6.2" id="the-history-interface"><span class="secno">6.6.2. </span><span class="content">The <code>History</code> interface</span><a class="self-link" href="browsers.html#the-history-interface"></a></h4>
<pre class="idl highlight def" data-highlight="webidl"><span class="kt">enum</span> <dfn class="nv dfn-paneled idl-code" data-dfn-for="ScrollRestoration" data-dfn-type="enum" data-export="" id="enumdef-scrollrestoration-scrollrestoration">ScrollRestoration</dfn> { <dfn class="s idl-code" data-dfn-for="ScrollRestoration" data-dfn-type="enum-value" data-export="" data-lt="&quot;auto&quot;|auto" id="dom-scrollrestoration-auto">"auto"<a class="self-link" href="browsers.html#dom-scrollrestoration-auto"></a></dfn>, <dfn class="s idl-code" data-dfn-for="ScrollRestoration" data-dfn-type="enum-value" data-export="" data-lt="&quot;manual&quot;|manual" id="dom-scrollrestoration-manual">"manual"<a class="self-link" href="browsers.html#dom-scrollrestoration-manual"></a></dfn> };
</pre>
<pre class="idl highlight def" data-highlight="webidl"><span class="kt">interface</span> <dfn class="nv dfn-paneled idl-code" data-dfn-for="History" data-dfn-type="interface" data-export="" id="history-history">History</dfn> {
  <span class="kt">readonly</span> <span class="kt">attribute</span> <span class="kt">unsigned</span> <span class="kt">long</span> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="unsigned long" href="browsers.html#dom-history-length" id="ref-for-dom-history-length-1">length</a>;
  <span class="kt">attribute</span> <a class="n" data-link-type="idl-name" href="browsers.html#enumdef-scrollrestoration-scrollrestoration" id="ref-for-enumdef-scrollrestoration-scrollrestoration-1">ScrollRestoration</a> <a class="nv idl-code" data-link-type="attribute" data-type="ScrollRestoration" href="browsers.html#dom-history-scrollrestoration" id="ref-for-dom-history-scrollrestoration-1">scrollRestoration</a>;
  <span class="kt">readonly</span> <span class="kt">attribute</span> <span class="kt">any</span> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="any" href="browsers.html#dom-history-state" id="ref-for-dom-history-state-1">state</a>;
  <span class="kt">void</span> <a class="nv idl-code" data-link-type="method" href="browsers.html#dom-history-go" id="ref-for-dom-history-go-1">go</a>(<span class="kt">optional</span> <span class="kt">long</span> <dfn class="nv idl-code" data-dfn-for="History/go(delta), History/go()" data-dfn-type="argument" data-export="" id="dom-history-go-delta-delta">delta<a class="self-link" href="browsers.html#dom-history-go-delta-delta"></a></dfn> = 0);
  <span class="kt">void</span> <a class="nv idl-code" data-link-type="method" href="browsers.html#dom-history-back" id="ref-for-dom-history-back-1">back</a>();
  <span class="kt">void</span> <a class="nv idl-code" data-link-type="method" href="browsers.html#dom-history-forward" id="ref-for-dom-history-forward-1">forward</a>();
  <span class="kt">void</span> <a class="nv idl-code" data-link-type="method" href="browsers.html#dom-history-pushstate" id="ref-for-dom-history-pushstate-2">pushState</a>(<span class="kt">any</span> <dfn class="nv idl-code" data-dfn-for="History/pushState(data, title, url), History/pushState(data, title)" data-dfn-type="argument" data-export="" id="dom-history-pushstate-data-title-url-data">data<a class="self-link" href="browsers.html#dom-history-pushstate-data-title-url-data"></a></dfn>, <span class="kt">DOMString</span> <dfn class="nv idl-code" data-dfn-for="History/pushState(data, title, url), History/pushState(data, title)" data-dfn-type="argument" data-export="" id="dom-history-pushstate-data-title-url-title">title<a class="self-link" href="browsers.html#dom-history-pushstate-data-title-url-title"></a></dfn>, <span class="kt">optional</span> <span class="kt">DOMString</span>? <dfn class="nv idl-code" data-dfn-for="History/pushState(data, title, url), History/pushState(data, title)" data-dfn-type="argument" data-export="" id="dom-history-pushstate-data-title-url-url">url<a class="self-link" href="browsers.html#dom-history-pushstate-data-title-url-url"></a></dfn> = <span class="kt">null</span>);
  <span class="kt">void</span> <a class="nv idl-code" data-link-type="method" href="browsers.html#dom-history-replacestate" id="ref-for-dom-history-replacestate-1">replaceState</a>(<span class="kt">any</span> <dfn class="nv idl-code" data-dfn-for="History/replaceState(data, title, url), History/replaceState(data, title)" data-dfn-type="argument" data-export="" id="dom-history-replacestate-data-title-url-data">data<a class="self-link" href="browsers.html#dom-history-replacestate-data-title-url-data"></a></dfn>, <span class="kt">DOMString</span> <dfn class="nv idl-code" data-dfn-for="History/replaceState(data, title, url), History/replaceState(data, title)" data-dfn-type="argument" data-export="" id="dom-history-replacestate-data-title-url-title">title<a class="self-link" href="browsers.html#dom-history-replacestate-data-title-url-title"></a></dfn>, <span class="kt">optional</span> <span class="kt">DOMString</span>? <dfn class="nv idl-code" data-dfn-for="History/replaceState(data, title, url), History/replaceState(data, title)" data-dfn-type="argument" data-export="" id="dom-history-replacestate-data-title-url-url">url<a class="self-link" href="browsers.html#dom-history-replacestate-data-title-url-url"></a></dfn> = <span class="kt">null</span>);
};
</pre>
    <dl class="domintro">
     <dt><var>window</var> . <code>history</code> . <code>length</code>
     </dt><dd>
      <p>Returns the number of entries in the <a data-link-type="dfn" href="browsers.html#joint-session-history" id="ref-for-joint-session-history-1">joint session history</a>.</p>
     </dd><dt><var>window</var> . <code>history</code> . <code>scrollRestoration</code> [ = <var>value</var> ]
     </dt><dd>
      <p>Returns the <a data-link-type="dfn" href="browsers.html#scroll-restoration-mode" id="ref-for-scroll-restoration-mode-3">scroll restoration mode</a> of the current entry in the <a data-link-type="dfn" href="browsers.html#session-history" id="ref-for-session-history-11">session history</a>.</p>
      <p>Can be set, to change the <a data-link-type="dfn" href="browsers.html#scroll-restoration-mode" id="ref-for-scroll-restoration-mode-4">scroll restoration mode</a> of the current entry in the <a data-link-type="dfn" href="browsers.html#session-history" id="ref-for-session-history-12">session history</a>.</p>
     </dd><dt><var>window</var> . <code>history</code> . <code>state</code>
     </dt><dd>
      <p>Returns the current <a data-link-type="dfn" href="browsers.html#state-object" id="ref-for-state-object-7">state object</a>.</p>
     </dd><dt><var>window</var> . <code>history</code> . <code>go</code>( [ <var>delta</var> ] )
     </dt><dd>
      <p>Goes back or forward the specified number of steps in the <a data-link-type="dfn" href="browsers.html#joint-session-history" id="ref-for-joint-session-history-2">joint session history</a>.</p>
      <p>A zero delta will reload the current page.</p>
      <p>If the delta is out of range, does nothing.</p>
     </dd><dt><var>window</var> . <code>history</code> . <code>back</code>()
     </dt><dd>
      <p>Goes back one step in the <a data-link-type="dfn" href="browsers.html#joint-session-history" id="ref-for-joint-session-history-3">joint session history</a>.</p>
      <p>If there is no previous page, does nothing.</p>
     </dd><dt><var>window</var> . <code>history</code> . <code>forward</code>()
     </dt><dd>
      <p>Goes forward one step in the <a data-link-type="dfn" href="browsers.html#joint-session-history" id="ref-for-joint-session-history-4">joint session history</a>.</p>
      <p>If there is no next page, does nothing.</p>
     </dd><dt><var>window</var> . <code>history</code> . <code>pushState</code>(<var>data</var>, <var>title</var> [, <var>url</var> ] )
     </dt><dd>
      <p>Pushes the given data onto the session history, with the given title, and, if provided and
    not null, the given URL.</p>
     </dd><dt><var>window</var> . <code>history</code> . <code>replaceState</code>(<var>data</var>, <var>title</var> [, <var>url</var> ] )
     </dt><dd>
      <p>Updates the current entry in the session history to have the given data, title, and, if
    provided and not null, URL.</p>
    </dd></dl>
    <p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="joint-session-history">joint session history</dfn> of a <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-53">top-level browsing context</a> is the union
  of all the <a data-link-type="dfn" href="browsers.html#session-history" id="ref-for-session-history-13">session histories</a> of all <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-203">browsing contexts</a> of all the <a data-link-type="dfn" href="browsers.html#fully-active" id="ref-for-fully-active-20">fully active</a> <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> objects that share that <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-54">top-level browsing context</a>, with all the entries that are <a data-link-type="dfn" href="browsers.html#current-entry" id="ref-for-current-entry-4">current entries</a> in their respective <a data-link-type="dfn" href="browsers.html#session-history" id="ref-for-session-history-14">session histories</a> removed except for the <a data-link-type="dfn" href="browsers.html#current-entry-of-the-joint-session-history" id="ref-for-current-entry-of-the-joint-session-history-1">current entry of the joint session
  history</a>.</p>
    <p>The <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="current-entry-of-the-joint-session-history">current entry of the joint session history</dfn> is the entry that most recently
  became a <a data-link-type="dfn" href="browsers.html#current-entry" id="ref-for-current-entry-5">current entry</a> in its <a data-link-type="dfn" href="browsers.html#session-history" id="ref-for-session-history-15">session history</a>.</p>
    <p>Entries in the <a data-link-type="dfn" href="browsers.html#joint-session-history" id="ref-for-joint-session-history-5">joint session history</a> are ordered chronologically by the time they
  were added to their respective <a data-link-type="dfn" href="browsers.html#session-history" id="ref-for-session-history-16">session histories</a>. Each entry
  has an index; the earliest entry has index 0, and the subsequent entries are numbered with
  consecutively increasing integers (1, 2, 3, etc).</p>
    <p class="note" role="note"> Since each <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> in a <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-204">browsing context</a> might have a
  different <a data-link-type="dfn" href="webappapis.html#event-loop" id="ref-for-event-loop-30">event loop</a>, the actual state of the <a data-link-type="dfn" href="browsers.html#joint-session-history" id="ref-for-joint-session-history-6">joint session history</a> can
  be somewhat nebulous. For example, two sibling <code><a data-link-type="element" href="semantics-embedded-content.html#elementdef-iframe" id="ref-for-elementdef-iframe-59">iframe</a></code> elements could both <a data-link-type="dfn" href="https://www.w3.org/TR/dom/#concept-nodeiterator-traverse">traverse</a> from one unique origin to another at the same time,
  so their precise order might not be well-defined; similarly, since they might only find out about
  each other later, they might disagree about the length of the <a data-link-type="dfn" href="browsers.html#joint-session-history" id="ref-for-joint-session-history-7">joint session
  history</a>. </p>
    <div class="impl">
     <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="History" data-dfn-type="attribute" data-export="" id="dom-history-length"><code>length</code></dfn> attribute of the <code>History</code> interface, on getting, must return the number of entries in the <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-55">top-level browsing context</a>’s <a data-link-type="dfn" href="browsers.html#joint-session-history" id="ref-for-joint-session-history-8">joint session history</a>. If this <code>History</code> object is associated with a <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> that is not <a data-link-type="dfn" href="browsers.html#fully-active" id="ref-for-fully-active-21">fully active</a>, getting must instead throw a "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#securityerror">SecurityError</a></code>" <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/WebIDL-1/#idl-DOMException">DOMException</a></code>.</p>
     <p>The actual entries are not accessible from script.</p>
     <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="History" data-dfn-type="attribute" data-export="" id="dom-history-scrollrestoration"><code>scrollRestoration</code></dfn> attribute
  of the History interface, on getting, must return the <a data-link-type="dfn" href="browsers.html#scroll-restoration-mode" id="ref-for-scroll-restoration-mode-5">scroll restoration mode</a> of the
  current entry in the <a data-link-type="dfn" href="browsers.html#session-history" id="ref-for-session-history-17">session history</a>. On setting, the <a data-link-type="dfn" href="browsers.html#scroll-restoration-mode" id="ref-for-scroll-restoration-mode-6">scroll restoration mode</a> of the current entry in the <a data-link-type="dfn" href="browsers.html#session-history" id="ref-for-session-history-18">session history</a> must be set to the new
  value. If this <code>History</code> object is associated with a <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> that is
  not <a data-link-type="dfn" href="browsers.html#fully-active" id="ref-for-fully-active-22">fully active</a>, both getting and setting must instead throw a
  "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#securityerror">SecurityError</a></code>" <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/WebIDL-1/#idl-DOMException">DOMException</a></code>.</p>
     <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="History" data-dfn-type="attribute" data-export="" id="dom-history-state"><code>state</code></dfn> attribute of the <code>History</code> interface, on getting, must return the last value it was set to by the user
  agent. If this <code>History</code> object is associated with a <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> that is
  not <a data-link-type="dfn" href="browsers.html#fully-active" id="ref-for-fully-active-23">fully active</a>, getting must instead throw a <code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#securityerror">SecurityError</a></code> <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/WebIDL-1/#idl-DOMException">DOMException</a></code>.
  Initially, its value must be null.</p>
     <p>When the <dfn class="dfn-paneled idl-code" data-dfn-for="History" data-dfn-type="method" data-export="" data-lt="go(delta)|go()" id="dom-history-go"><code>go(<var>delta</var>)</code></dfn> method is
  invoked, if <var>delta</var> is zero, the user agent must act as if the <code>location.reload()</code> method was called instead. Otherwise,
  the user agent must <a data-link-type="dfn" href="browsers.html#explicitly-going-back-or-forwards-in-the-session-history" id="ref-for-explicitly-going-back-or-forwards-in-the-session-history-1">traverse the history by a delta</a> whose value is <var>delta</var> If this <code>History</code> object is associated with a <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> that is not <span>fully active</span>, invoking must instead throw a
  "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#securityerror">SecurityError</a></code>" <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/WebIDL-1/#idl-DOMException">DOMException</a></code>.</p>
     <p>When the <dfn class="dfn-paneled idl-code" data-dfn-for="History" data-dfn-type="method" data-export="" id="dom-history-back"><code>back()</code></dfn> method is invoked, the user
  agent must <a data-link-type="dfn" href="browsers.html#explicitly-going-back-or-forwards-in-the-session-history" id="ref-for-explicitly-going-back-or-forwards-in-the-session-history-2">traverse the history by a delta</a> −1. If this <code>History</code> object is associated with a <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> that is not <a data-link-type="dfn" href="browsers.html#fully-active" id="ref-for-fully-active-24">fully active</a>,
  invoking must instead throw a "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#securityerror">SecurityError</a></code>" <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/WebIDL-1/#idl-DOMException">DOMException</a></code>.</p>
     <p>When the <dfn class="dfn-paneled idl-code" data-dfn-for="History" data-dfn-type="method" data-export="" id="dom-history-forward"><code>forward()</code></dfn>method is invoked, the
  user agent must <a data-link-type="dfn" href="browsers.html#explicitly-going-back-or-forwards-in-the-session-history" id="ref-for-explicitly-going-back-or-forwards-in-the-session-history-3">traverse the history by a delta</a> +1. If this <code>History</code> object is associated with a <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> that is not <a data-link-type="dfn" href="browsers.html#fully-active" id="ref-for-fully-active-25">fully active</a>,
  invoking must instead throw a "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#securityerror">SecurityError</a></code>" <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/WebIDL-1/#idl-DOMException">DOMException</a></code>.</p>
     <hr>
     <p>Each <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-56">top-level browsing context</a> has a <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="session-history-traversal-queue">session history traversal queue</dfn>,
  initially empty, to which <a data-link-type="dfn" href="webappapis.html#tasks" id="ref-for-tasks-68">tasks</a> can be added.</p>
     <p>Each <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-57">top-level browsing context</a>, when created, must begin running
  the following algorithm, known as the <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="session-history-event-loop">session history event loop</dfn> for that <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-58">top-level browsing context</a>, <a data-link-type="dfn" href="infrastructure.html#in-parallel" id="ref-for-in-parallel-27">in parallel</a>:</p>
     <ol>
      <li>Wait until this <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-59">top-level browsing context</a>’s <a data-link-type="dfn" href="browsers.html#session-history-traversal-queue" id="ref-for-session-history-traversal-queue-1">session history traversal
    queue</a> is not empty.
      </li><li>Pull the first <a data-link-type="dfn" href="webappapis.html#tasks" id="ref-for-tasks-69">task</a> from this <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-60">top-level browsing
    context</a>’s <a data-link-type="dfn" href="browsers.html#session-history-traversal-queue" id="ref-for-session-history-traversal-queue-2">session history traversal queue</a>, and execute it.
      </li><li>Return to the first step of this algorithm. 
     </li></ol>
     <p>The <a data-link-type="dfn" href="browsers.html#session-history-event-loop" id="ref-for-session-history-event-loop-1">session history event loop</a> helps coordinate cross-browsing-context transitions
  of the <a data-link-type="dfn" href="browsers.html#joint-session-history" id="ref-for-joint-session-history-9">joint session history</a>: since each <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-205">browsing context</a> might, at any
  particular time, have a different <a data-link-type="dfn" href="webappapis.html#event-loop" id="ref-for-event-loop-31">event loop</a> (this can happen if the user agent has
  more than one <a data-link-type="dfn" href="webappapis.html#event-loop" id="ref-for-event-loop-32">event loop</a> per <a data-link-type="dfn" href="browsers.html#unit-of-related-browsing-contexts" id="ref-for-unit-of-related-browsing-contexts-2">unit of related browsing contexts</a>),
  transitions would otherwise have to involve cross-event-loop synchronization.</p>
     <hr>
     <p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="explicitly going back or forwards in the session history|traverse the history by a delta" data-noexport="" id="explicitly-going-back-or-forwards-in-the-session-history">traverse the history by a delta</dfn> <var>delta</var>, the user agent must
  append a <a data-link-type="dfn" href="webappapis.html#tasks" id="ref-for-tasks-70">task</a> to this <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-61">top-level browsing context</a>’s <a data-link-type="dfn" href="browsers.html#session-history-traversal-queue" id="ref-for-session-history-traversal-queue-3">session history traversal queue</a>, the <a data-link-type="dfn" href="webappapis.html#tasks" id="ref-for-tasks-71">task</a> consisting of running the following steps:</p>
     <ol>
      <li>If the index of the <a data-link-type="dfn" href="browsers.html#current-entry-of-the-joint-session-history" id="ref-for-current-entry-of-the-joint-session-history-2">current entry of the joint session history</a> plus <var>delta</var> is less than zero or greater than or equal to the number of items in the <a data-link-type="dfn" href="browsers.html#joint-session-history" id="ref-for-joint-session-history-10">joint session history</a>, then abort these steps. 
      </li><li>Let <var>specified entry</var> be the entry in the <a data-link-type="dfn" href="browsers.html#joint-session-history" id="ref-for-joint-session-history-11">joint session
    history</a> whose index is the sum of <var>delta</var> and the index of the <a data-link-type="dfn" href="browsers.html#current-entry-of-the-joint-session-history" id="ref-for-current-entry-of-the-joint-session-history-3">current entry of the joint session history</a>.
      </li><li>Let <var>specified browsing context</var> be the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-206">browsing context</a> of
    the <var>specified entry</var>.
      </li><li>If the <var>specified browsing context</var>’s <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-66">active document</a>’s <a data-link-type="dfn" href="browsers.html#unloaded" id="ref-for-unloaded-4">unload a document</a> algorithm is currently running, abort these steps.
      </li><li>
       <p><a data-link-type="dfn" href="webappapis.html#queuing" id="ref-for-queuing-117">Queue a task</a> that consists of running the following substeps. The relevant <a data-link-type="dfn" href="webappapis.html#event-loop" id="ref-for-event-loop-33">event loop</a> is that of the <var>specified browsing context</var>’s <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-67">active document</a>. The <a data-link-type="dfn" href="webappapis.html#task-source" id="ref-for-task-source-17">task source</a> for the queued task is the <a data-link-type="dfn" href="webappapis.html#history-traversal-task-source" id="ref-for-history-traversal-task-source-1">history traversal task source</a>.</p>
       <ol>
        <li>If there is an ongoing attempt to navigate <var>specified browsing context</var> that has not yet <a data-link-type="dfn" href="browsers.html#matured" id="ref-for-matured-1">matured</a> (i.e., it has not passed the
      point of making its <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> the <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-68">active document</a>), then cancel that
      attempt to navigate the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-207">browsing context</a>.
        </li><li>
         <p>If the <var>specified browsing context</var>’s <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-69">active document</a> is not
      the same <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> as the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> of the <var>specified
      entry</var>, then run these substeps:</p>
         <ol>
          <li><a data-link-type="dfn" href="browsers.html#prompt-to-unload" id="ref-for-prompt-to-unload-2">Prompt to unload</a> the <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-70">active
        document</a> of the <var>specified browsing context</var>. If the user <a data-link-type="dfn" href="browsers.html#refused-to-allow-the-document-to-be-unloaded" id="ref-for-refused-to-allow-the-document-to-be-unloaded-2">refused to allow the document to be unloaded</a>, then abort these steps.
          </li><li><a data-link-type="dfn" href="browsers.html#unloaded" id="ref-for-unloaded-5">Unload</a> the <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-71">active document</a> of the <var>specified browsing context</var> with the <var>recycle</var> parameter
        set to false.
         </li></ol>
        </li><li><a data-link-type="dfn" href="browsers.html#traverse-the-history" id="ref-for-traverse-the-history-3">Traverse the history</a> of the <var>specified browsing context</var> to
      the <var>specified entry</var>. 
       </li></ol>
     </li></ol>
     <p>When the user navigates through a <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-208">browsing context</a>, e.g., using a browser’s back
  and forward buttons, the user agent must <a data-link-type="dfn" href="browsers.html#explicitly-going-back-or-forwards-in-the-session-history" id="ref-for-explicitly-going-back-or-forwards-in-the-session-history-4">traverse the history by a delta</a> equivalent
  to the action specified by the user.</p>
     <hr>
     <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="History" data-dfn-type="method" data-export="" data-lt="pushState(data, title, url)|pushState(data, title)" id="dom-history-pushstate"><code>pushState()</code></dfn> method adds a state object entry to
  the history.</p>
     <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="History" data-dfn-type="method" data-export="" data-lt="replaceState(data, title, url)|replaceState(data, title)" id="dom-history-replacestate"><code>replaceState()</code></dfn> method updates the state object,
  title, and optionally the <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a> of the <a data-link-type="dfn" href="browsers.html#current-entry" id="ref-for-current-entry-6">current entry</a> in the history.</p>
     <p>When either of these methods is invoked, the user agent must run the following steps:</p>
     <ol>
      <li data-md="">
       <p>If this <code class="idl"><a data-link-type="idl" href="browsers.html#history-history" id="ref-for-history-history-2">History</a></code> object is associated with a <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> that is not <a data-link-type="dfn" href="browsers.html#fully-active" id="ref-for-fully-active-26">fully active</a>,
  throw a "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#securityerror">SecurityError</a></code>" <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/WebIDL-1/#idl-DOMException">DOMException</a></code>.</p>
      </li><li data-md="">
       <p>Optionally, abort these steps. (For example, the user agent might disallow calls to these
  methods that are invoked on a timer, or from event listeners that are not triggered in
  response to a clear user action, or that are invoked in rapid succession.)</p>
      </li><li data-md="">
       <p>Let <var>targetRealm</var> be this <code class="idl"><a data-link-type="idl" href="browsers.html#history-history" id="ref-for-history-history-3">History</a></code> object’s <a data-link-type="dfn" href="webappapis.html#relevant-settings-object" id="ref-for-relevant-settings-object-2">relevant settings object</a>’s <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-code-realms">Realm</a>.</p>
      </li><li data-md="">
       <p>Let <var>cloned data</var> be a <a data-link-type="dfn" href="infrastructure.html#structuredclone" id="ref-for-structuredclone-12">StructuredClone</a>(<var>data</var>, <var>targetRealm</var>). Rethrow any exceptions.</p>
      </li><li data-md="">
       <p>If the third argument is not null, run these substeps:</p>
       <ol>
        <li data-md="">
         <p><a data-link-type="dfn" href="infrastructure.html#reparsed" id="ref-for-reparsed-37">Parse</a> the value of the third argument, relative to the <a data-link-type="dfn" href="webappapis.html#entry-settings-object" id="ref-for-entry-settings-object-7">entry settings object</a>.</p>
        </li><li data-md="">
         <p>If that fails, throw a "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#securityerror">SecurityError</a></code>" <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/WebIDL-1/#idl-DOMException">DOMException</a></code> and abort these steps.</p>
        </li><li data-md="">
         <p>Let <var>new URL</var> be the <a data-link-type="dfn" href="infrastructure.html#resulting-url-record" id="ref-for-resulting-url-record-11">resulting URL record</a>.</p>
        </li><li data-md="">
         <p>Compare <var>new URL</var> to the document’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a>. If any component of
  these two <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url">URL records</a> differ other than the <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-path">path</a>, <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-query">query</a>, and <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-fragment">fragment</a> components, then throw a
  "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#securityerror">SecurityError</a></code>" <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/WebIDL-1/#idl-DOMException">DOMException</a></code> and abort these steps.</p>
        </li><li data-md="">
         <p>If the <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-origin">origin</a> of <var>new URL</var> is not the same as the <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-66">origin</a> of the <a data-link-type="dfn" href="webappapis.html#responsible-document" id="ref-for-responsible-document-4">responsible document</a> specified by the <a data-link-type="dfn" href="webappapis.html#entry-settings-object" id="ref-for-entry-settings-object-8">entry settings object</a>, and either the <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-path">path</a> or <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-query">query</a> components of the two <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url">URL records</a> compared in the previous step differ, throw a
  "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#securityerror">SecurityError</a></code>" <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/WebIDL-1/#idl-DOMException">DOMException</a></code> and abort these steps. (This prevents
  sandboxed content from spoofing other pages on the same origin.)</p>
       </li></ol>
      </li><li data-md="">
       <p>If the third argument is null, then let <var>new URL</var> be the <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a> of the <a data-link-type="dfn" href="browsers.html#current-entry" id="ref-for-current-entry-7">current entry</a>.</p>
      </li><li data-md="">
       <p>If the method invoked was the <code class="idl"><a data-link-type="idl" href="browsers.html#dom-history-pushstate" id="ref-for-dom-history-pushstate-3">pushState()</a></code> method:</p>
       <ol>
        <li data-md="">
         <p>Remove all the entries in the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-209">browsing context</a>’s <a data-link-type="dfn" href="browsers.html#session-history" id="ref-for-session-history-19">session history</a> after the <a data-link-type="dfn" href="browsers.html#current-entry" id="ref-for-current-entry-8">current entry</a>. If the <a data-link-type="dfn" href="browsers.html#current-entry" id="ref-for-current-entry-9">current entry</a> is the last entry in the session
  history, then no entries are removed.</p>
         <p class="note" role="note">This <a data-link-type="dfn" href="browsers.html#doesnt-necessarily-have-to-affect" id="ref-for-doesnt-necessarily-have-to-affect-1">doesn’t necessarily have to affect</a> the user agent’s user
  interface.</p>
        </li><li data-md="">
         <p>Remove any <a data-link-type="dfn" href="webappapis.html#tasks" id="ref-for-tasks-72">tasks</a> queued by the <a data-link-type="dfn" href="webappapis.html#history-traversal-task-source" id="ref-for-history-traversal-task-source-2">history traversal task source</a> that are
  associated with any <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> objects in the <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-62">top-level browsing context</a>’s <a data-link-type="dfn" href="browsers.html#document-family" id="ref-for-document-family-4">document family</a>.</p>
        </li><li data-md="">
         <p>If appropriate, update the <a data-link-type="dfn" href="browsers.html#current-entry" id="ref-for-current-entry-10">current entry</a> to reflect any state that the user agent
  wishes to persist. The entry is then said to be <a data-link-type="dfn" href="browsers.html#an-entry-with-persisted-user-state" id="ref-for-an-entry-with-persisted-user-state-1">an entry with persisted user state</a>.</p>
        </li><li data-md="">
         <p>Add a <a data-link-type="dfn" href="browsers.html#state-object" id="ref-for-state-object-8">state object</a> entry to the session history, after the <a data-link-type="dfn" href="browsers.html#current-entry" id="ref-for-current-entry-11">current entry</a>,
  with <var>cloned data</var> as the <a data-link-type="dfn" href="browsers.html#state-object" id="ref-for-state-object-9">state object</a>, the given <var>title</var> as the
  title, <var>new URL</var> as the <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a> of the entry, and the <a data-link-type="dfn" href="browsers.html#scroll-restoration-mode" id="ref-for-scroll-restoration-mode-7">scroll restoration mode</a> of the current entry in the <a data-link-type="dfn" href="browsers.html#session-history" id="ref-for-session-history-20">session history</a> as the
  scroll restoration mode.</p>
        </li><li data-md="">
         <p>Update the <a data-link-type="dfn" href="browsers.html#current-entry" id="ref-for-current-entry-12">current entry</a> to be this newly added entry.</p>
       </li></ol>
       <p>Otherwise, if the method invoked was the <code class="idl"><a data-link-type="idl" href="browsers.html#dom-history-replacestate" id="ref-for-dom-history-replacestate-2">replaceState()</a></code> method:</p>
       <ol>
        <li data-md="">
         <p>Update the <a data-link-type="dfn" href="browsers.html#current-entry" id="ref-for-current-entry-13">current entry</a> in the session history so that <var>cloned data</var> is
  the entry’s new state object, the given <var>title</var> is the new title, and <var>new URL</var> is the entry’s new <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a>.</p>
       </li></ol>
      </li><li data-md="">
       <p>If the <a data-link-type="dfn" href="browsers.html#current-entry" id="ref-for-current-entry-14">current entry</a> in the session history represents a non-GET request (e.g., it was
  the result of a POST submission) then update it to instead represent a GET request.</p>
      </li><li data-md="">
       <p>Set the document’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a> to <var>new URL</var>.</p>
       <p class="note" role="note">Since this is neither a <a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-54">navigation</a> of the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-210">browsing context</a> nor a <a data-link-type="dfn" href="browsers.html#traverse-the-history" id="ref-for-traverse-the-history-4">history traversal</a>, it does not cause a <code>hashchange</code> event to be fired.</p>
      </li><li data-md="">
       <p>Let <var>targetRealm</var> be this <code class="idl"><a data-link-type="idl" href="browsers.html#history-history" id="ref-for-history-history-4">History</a></code> object’s <a data-link-type="dfn" href="webappapis.html#relevant-settings-object" id="ref-for-relevant-settings-object-3">relevant settings object</a>’s <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-code-realms">Realm</a>.</p>
      </li><li data-md="">
       <p>Set <code class="idl"><a data-link-type="idl" href="browsers.html#dom-history-state" id="ref-for-dom-history-state-2">history.state</a></code> to <a data-link-type="dfn" href="infrastructure.html#structuredclone" id="ref-for-structuredclone-13">StructuredClone</a>(<var>cloned data</var>, <var>targetRealm</var>).</p>
      </li><li data-md="">
       <p>Let the <a data-link-type="dfn" href="browsers.html#latest-entry" id="ref-for-latest-entry-2">latest entry</a> of the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> of the <a data-link-type="dfn" href="browsers.html#current-entry" id="ref-for-current-entry-15">current entry</a> be the <a data-link-type="dfn" href="browsers.html#current-entry" id="ref-for-current-entry-16">current entry</a>.</p>
     </li></ol>
     <p class="note" role="note">The <var>title</var> is purely advisory. User agents might use the title in the
  user interface.</p>
     <p>User agents may limit the number of state objects added to the session history per page. If a
  page hits the user agent-defined limit, user agents must remove the entry immediately after the
  first entry for that <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object in the session history after having added the new
  entry. (Thus the state history acts as a FIFO buffer for eviction, but as a LIFO buffer for
  navigation.)</p>
    </div>
    <div class="example" id="example-ce142ed6">
     <a class="self-link" href="browsers.html#example-ce142ed6"></a> Consider a game where the user can navigate along a line, such that the user is always at some
    coordinate, and such that the user can bookmark the page corresponding to a particular
    coordinate, to return to it later. 
     <p>A static page implementing the x=5 position in such a game could look like the following:</p>
<pre class="highlight"><span class="cp">&lt;!DOCTYPE HTML&gt;</span>
<span class="c">&lt;!-- this is https://example.com/line?x=5 --&gt;</span>
<span class="nt">&lt;title&gt;</span>Line Game - 5<span class="nt">&lt;/title&gt;</span>
<span class="nt">&lt;p&gt;</span>You are at coordinate 5 on the line.<span class="nt">&lt;/p&gt;</span>
<span class="nt">&lt;p&gt;</span>
<span class="nt">&lt;a</span> <span class="na">href=</span><span class="s">"?x=6"</span><span class="nt">&gt;</span>Advance to 6<span class="nt">&lt;/a&gt;</span> or
<span class="nt">&lt;a</span> <span class="na">href=</span><span class="s">"?x=4"</span><span class="nt">&gt;</span>retreat to 4<span class="nt">&lt;/a&gt;</span>?
<span class="nt">&lt;/p&gt;</span>
</pre>
     <p>The problem with such a system is that each time the user clicks, the whole page has to be
    reloaded. Here instead is another way of doing it, using script:</p>
<pre class="highlight"><span class="cp">&lt;!DOCTYPE HTML&gt;</span>
<span class="c">&lt;!-- this starts off as https://example.com/line?x=5 --&gt;</span>
<span class="nt">&lt;title&gt;</span>Line Game - 5<span class="nt">&lt;/title&gt;</span>
<span class="nt">&lt;p&gt;</span>You are at coordinate <span class="nt">&lt;span&gt;</span>5<span class="nt">&lt;/span&gt;</span> on the line.<span class="nt">&lt;/p&gt;</span>
<span class="nt">&lt;p&gt;</span>
<span class="nt">&lt;a</span> <span class="na">href=</span><span class="s">"?x=6"</span> <span class="na">onclick=</span><span class="s">"go(1); return false;"</span><span class="nt">&gt;</span>Advance to 6<span class="nt">&lt;/a&gt;</span> or
<span class="nt">&lt;a</span> <span class="na">href=</span><span class="s">"?x=4"</span> <span class="na">onclick=</span><span class="s">"go(-1); return false;"</span><span class="nt">&gt;</span>retreat to 4<span class="nt">&lt;/a&gt;</span>?
<span class="nt">&lt;/p&gt;</span>
<span class="nt">&lt;script&gt;</span>
<span class="kd">var</span> <span class="nx">currentPage</span> <span class="o">=</span> <span class="mi">5</span><span class="p">;</span> <span class="c1">// prefilled by server</span>
<span class="kd">function</span> <span class="nx">go</span><span class="p">(</span><span class="nx">d</span><span class="p">)</span> <span class="p">{</span>
  <span class="nx">setupPage</span><span class="p">(</span><span class="nx">currentPage</span> <span class="o">+</span> <span class="nx">d</span><span class="p">);</span>
  <span class="nx">history</span><span class="p">.</span><span class="nx">pushState</span><span class="p">(</span><span class="nx">currentPage</span><span class="p">,</span> <span class="nb">document</span><span class="p">.</span><span class="nx">title</span><span class="p">,</span> <span class="s1">'?x='</span> <span class="o">+</span> <span class="nx">currentPage</span><span class="p">);</span>
<span class="p">}</span>
<span class="nx">onpopstate</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">event</span><span class="p">)</span> <span class="p">{</span>
  <span class="nx">setupPage</span><span class="p">(</span><span class="nx">event</span><span class="p">.</span><span class="nx">state</span><span class="p">);</span>
<span class="p">}</span>
<span class="kd">function</span> <span class="nx">setupPage</span><span class="p">(</span><span class="nx">page</span><span class="p">)</span> <span class="p">{</span>
  <span class="nx">currentPage</span> <span class="o">=</span> <span class="nx">page</span><span class="p">;</span>
  <span class="nb">document</span><span class="p">.</span><span class="nx">title</span> <span class="o">=</span> <span class="s1">'Line Game - '</span> <span class="o">+</span> <span class="nx">currentPage</span><span class="p">;</span>
  <span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">'coord'</span><span class="p">).</span><span class="nx">textContent</span> <span class="o">=</span> <span class="nx">currentPage</span><span class="p">;</span>
  <span class="nb">document</span><span class="p">.</span><span class="nx">links</span><span class="p">[</span><span class="mi">0</span><span class="p">].</span><span class="nx">href</span> <span class="o">=</span> <span class="s1">'?x='</span> <span class="o">+</span> <span class="p">(</span><span class="nx">currentPage</span><span class="o">+</span><span class="mi">1</span><span class="p">);</span>
  <span class="nb">document</span><span class="p">.</span><span class="nx">links</span><span class="p">[</span><span class="mi">0</span><span class="p">].</span><span class="nx">textContent</span> <span class="o">=</span> <span class="s1">'Advance to '</span> <span class="o">+</span> <span class="p">(</span><span class="nx">currentPage</span><span class="o">+</span><span class="mi">1</span><span class="p">);</span>
  <span class="nb">document</span><span class="p">.</span><span class="nx">links</span><span class="p">[</span><span class="mi">1</span><span class="p">].</span><span class="nx">href</span> <span class="o">=</span> <span class="s1">'?x='</span> <span class="o">+</span> <span class="p">(</span><span class="nx">currentPage</span><span class="o">-</span><span class="mi">1</span><span class="p">);</span>
  <span class="nb">document</span><span class="p">.</span><span class="nx">links</span><span class="p">[</span><span class="mi">1</span><span class="p">].</span><span class="nx">textContent</span> <span class="o">=</span> <span class="s1">'retreat to '</span> <span class="o">+</span> <span class="p">(</span><span class="nx">currentPage</span><span class="o">-</span><span class="mi">1</span><span class="p">);</span>
<span class="p">}</span>
<span class="nt">&lt;/script&gt;</span>
</pre>
     <p>In systems without script, this still works like the previous example. However, users that <em>do</em> have script support can now navigate much faster, since there is no network access
    for the same experience. Furthermore, contrary to the experience the user would have with just a
    naïve script-based approach, bookmarking and navigating the session history still work.</p>
     <p>In the example above, the <var>data</var> argument to the <code>pushState()</code> method is the same information as would be sent
    to the server, but in a more convenient form, so that the script doesn’t have to parse the URL
    each time the user navigates.</p>
    </div>
    <div class="example" id="example-7e4f1b3c">
     <a class="self-link" href="browsers.html#example-7e4f1b3c"></a> Applications might not use the same title for a <a data-link-type="dfn" href="browsers.html#session-history-entry" id="ref-for-session-history-entry-5">session history entry</a> as the
    value of the document’s <a data-link-type="element" href="document-metadata.html#elementdef-title" id="ref-for-elementdef-title-25"><code>title</code></a> element at that time. For example, here is a simple
    page that shows a block in the <a data-link-type="element" href="document-metadata.html#elementdef-title" id="ref-for-elementdef-title-26"><code>title</code></a> element. Clearly, when navigating backwards to
    a previous state the user does not go back in time, and therefore it would be inappropriate to
    put the time in the session history title. 
<pre class="highlight"><span class="cp">&lt;!DOCTYPE HTML&gt;</span>
<span class="nt">&lt;TITLE&gt;</span>Line<span class="nt">&lt;/TITLE&gt;</span>
<span class="nt">&lt;SCRIPT&gt;</span>
<span class="nx">setInterval</span><span class="p">(</span><span class="kd">function</span> <span class="p">()</span> <span class="p">{</span> <span class="nb">document</span><span class="p">.</span><span class="nx">title</span> <span class="o">=</span> <span class="s1">'Line - '</span> <span class="o">+</span> <span class="k">new</span> <span class="nb">Date</span><span class="p">();</span> <span class="p">},</span> <span class="mi">1000</span><span class="p">);</span>
<span class="kd">var</span> <span class="nx">i</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span>
<span class="kd">function</span> <span class="nx">inc</span><span class="p">()</span> <span class="p">{</span>
  <span class="nx">set</span><span class="p">(</span><span class="nx">i</span><span class="o">+</span><span class="mi">1</span><span class="p">);</span>
  <span class="nx">history</span><span class="p">.</span><span class="nx">pushState</span><span class="p">(</span><span class="nx">i</span><span class="p">,</span> <span class="s1">'Line - '</span> <span class="o">+</span> <span class="nx">i</span><span class="p">);</span>
<span class="p">}</span>
<span class="kd">function</span> <span class="nx">set</span><span class="p">(</span><span class="nx">newI</span><span class="p">)</span> <span class="p">{</span>
  <span class="nx">i</span> <span class="o">=</span> <span class="nx">newI</span><span class="p">;</span>
  <span class="nb">document</span><span class="p">.</span><span class="nx">forms</span><span class="p">.</span><span class="nx">F</span><span class="p">.</span><span class="nx">I</span><span class="p">.</span><span class="nx">value</span> <span class="o">=</span> <span class="nx">newI</span><span class="p">;</span>
<span class="p">}</span>
<span class="nt">&lt;/SCRIPT&gt;</span>
<span class="nt">&lt;BODY</span> <span class="na">ONPOPSTATE=</span><span class="s">"set(event.state)"</span><span class="nt">&gt;</span>
<span class="nt">&lt;FORM</span> <span class="na">NAME=</span><span class="s">F</span><span class="nt">&gt;</span>
State: <span class="nt">&lt;OUTPUT</span> <span class="na">NAME=</span><span class="s">I</span><span class="nt">&gt;</span>1<span class="nt">&lt;/OUTPUT&gt;</span> <span class="nt">&lt;INPUT</span> <span class="na">VALUE=</span><span class="s">"Increment"</span> <span class="na">TYPE=</span><span class="s">BUTTON</span> <span class="na">ONCLICK=</span><span class="s">"inc()"</span><span class="nt">&gt;</span>
<span class="nt">&lt;/FORM&gt;</span>
</pre>
    </div>
    <div class="example" id="example-ffd92397">
     <a class="self-link" href="browsers.html#example-ffd92397"></a> Most applications want to use the same <a data-link-type="dfn" href="browsers.html#scroll-restoration-mode" id="ref-for-scroll-restoration-mode-8">scroll restoration mode</a> value for all of
    their history entries. To achieve this they should set the <code>scrollRestoration</code> attribute as soon as possible
    (e.g., in the first <code>script</code> element in the document’s <code><a data-link-type="element" href="document-metadata.html#elementdef-head" id="ref-for-elementdef-head-42">head</a></code> element) to
    ensure that any entry added to the history session gets the desired scroll restoration mode. 
<pre class="highlight"><span class="nt">&lt;head&gt;</span>
  <span class="nt">&lt;script&gt;</span>
    <span class="k">if</span> <span class="p">(</span><span class="s1">'scrollRestoration'</span> <span class="k">in</span> <span class="nx">history</span><span class="p">)</span>
      <span class="nx">history</span><span class="p">.</span><span class="nx">scrollRestoration</span> <span class="o">=</span> <span class="s1">'manual'</span><span class="p">;</span>
  <span class="nt">&lt;/script&gt;</span>
<span class="nt">&lt;/head&gt;</span>
</pre>
    </div>
    <h4 class="heading settled" data-level="6.6.3" id="sec-implementation-notes-for-session-history"><span class="secno">6.6.3. </span><span class="content"><dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="doesn’t necessarily have to affect|Implementation notes for session history" data-noexport="" id="doesnt-necessarily-have-to-affect">Implementation notes for session history</dfn></span><a class="self-link" href="browsers.html#sec-implementation-notes-for-session-history"></a></h4>
    <p><em>This section is non-normative</em>.</p>
    <p>The <code class="idl"><a data-link-type="idl" href="browsers.html#history-history" id="ref-for-history-history-5">History</a></code> interface is not meant to place restrictions on how implementations represent the
  session history to the user.</p>
    <p>For example, session history could be implemented in a tree-like manner, with each page having
  multiple "forward" pages. This specification doesn’t define how the linear list of pages in the <code class="idl"><a data-link-type="idl" href="browsers.html#dom-window-history" id="ref-for-dom-window-history-2">history</a></code> object are derived from the actual session history as seen from the user’s
  perspective.</p>
    <p>Similarly, a page containing two <code><a data-link-type="element" href="semantics-embedded-content.html#elementdef-iframe" id="ref-for-elementdef-iframe-60">iframe</a></code>s has a <code class="idl"><a data-link-type="idl" href="browsers.html#dom-window-history" id="ref-for-dom-window-history-3">history</a></code> object distinct from the <code><a data-link-type="element" href="semantics-embedded-content.html#elementdef-iframe" id="ref-for-elementdef-iframe-61">iframe</a></code>s' <code class="idl"><a data-link-type="idl" href="browsers.html#dom-window-history" id="ref-for-dom-window-history-4">history</a></code> objects, despite the fact that typical Web browsers present the
  user with just one "Back" button, with a session history that interleaves the navigation of the
  two inner frames and the outer page.</p>
    <p><em>Security</em>: It is suggested that to avoid letting a page "hijack" the history navigation
  facilities of a UA by abusing <code class="idl"><a data-link-type="idl" href="browsers.html#dom-history-pushstate" id="ref-for-dom-history-pushstate-4">pushState()</a></code>, the UA provide the user with a way to jump
  back to the previous page (rather than just going back to the previous state). For example, the
  back button could have a drop down showing just the pages in the session history, and not showing
  any of the states. Similarly, an aural browser could have two "back" commands, one that goes back
  to the previous state, and one that jumps straight back to the previous page.</p>
    <p>For both <code class="idl"><a data-link-type="idl" href="browsers.html#dom-history-pushstate" id="ref-for-dom-history-pushstate-5">pushState()</a></code> and <code class="idl"><a data-link-type="idl" href="browsers.html#dom-history-replacestate" id="ref-for-dom-history-replacestate-3">replaceState()</a></code>, user agents are encouraged to
  prevent abuse of these APIs via too-frequent calls or over-large state objects. As detailed above,
  the algorithm explicitly allows user agents to ignore any such calls when appropriate.</p>
    <h4 class="heading settled" data-level="6.6.4" id="the-location-interface"><span class="secno">6.6.4. </span><span class="content">The <code>Location</code> interface</span><a class="self-link" href="browsers.html#the-location-interface"></a></h4>
    <p>Each <code class="idl"><a data-link-type="idl" href="browsers.html#window-window" id="ref-for-window-window-35">Window</a></code> object is associated with a unique instance of a <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-10">Location</a></code> object, allocated
  when the <code class="idl"><a data-link-type="idl" href="browsers.html#window-window" id="ref-for-window-window-36">Window</a></code> object is created.</p>
    <p>To create a <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-11">Location</a></code> object, run these steps:</p>
    <ol>
     <li data-md="">
      <p>Let <var>location</var> be a new <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-12">Location</a></code> <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-platform-object">platform object</a>.</p>
     </li><li data-md="">
      <p>Perform ! <var>location</var>.[[DefineOwnProperty]]("<code>toString</code>", {
  [[Value]]: <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-object.prototype.tostring">%ObjProto_toString%</a>, [[Writable]]: false, [[Enumerable]]: false,
  [[Configurable]]: false }).</p>
     </li><li data-md="">
      <p>Perform ! <var>location</var>.[[DefineOwnProperty]]("<code>toJSON</code>", {
  [[Value]]: undefined, [[Writable]]: false, [[Enumerable]]: false,
  [[Configurable]]: false }).</p>
     </li><li data-md="">
      <p>Perform ! <var>location</var>.[[DefineOwnProperty]]("<code>valueOf</code>", {
  [[Value]]: <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-object.prototype.valueof">%ObjProto_valueOf%</a>, [[Writable]]: false, [[Enumerable]]: false,
  [[Configurable]]: false }).</p>
     </li><li data-md="">
      <p>Perform ! <var>location</var>.[[DefineOwnProperty]](<a data-link-type="dfn" href="infrastructure.html#toprimitive" id="ref-for-toprimitive-1">@@toPrimitive</a>, {
  [[Value]]: undefined, [[Writable]]: false, [[Enumerable]]: false,
  [[Configurable]]: false }).</p>
     </li><li data-md="">
      <p>Set the value of the [[<a data-link-type="dfn" href="browsers.html#defaultproperties" id="ref-for-defaultproperties-1">DefaultProperties</a>]] internal slot of <var>location</var> to <var>location</var>.[[OwnPropertyKeys]]().</p>
     </li><li data-md="">
      <p>Return <var>location</var>.</p>
    </li></ol>
    <dl class="domintro">
     <dt><var>document</var> . <code class="idl"><a data-link-type="idl" href="browsers.html#dom-document-location" id="ref-for-dom-document-location-2">location</a></code> [ = <var>value</var> ]
     </dt><dt><var>window</var> . <code class="idl"><a data-link-type="idl" href="browsers.html#dom-window-location" id="ref-for-dom-window-location-2">location</a></code> [ = <var>value</var> ]
     </dt><dd>
      Returns a <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-13">Location</a></code> object with the current page’s location. 
      <p>Can be set, to navigate to another page.</p>
    </dd></dl>
    <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="Document" data-dfn-type="attribute" data-export="" id="dom-document-location"><code>location</code></dfn> attribute of the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> interface must return the <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-14">Location</a></code> object for that <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object’s <a data-link-type="dfn" href="webappapis.html#global-object" id="ref-for-global-object-4">global object</a>,
  if it has a <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-211">browsing context</a>, and null otherwise.</p>
    <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="Window" data-dfn-type="attribute" data-export="" id="dom-window-location"><code>location</code></dfn> attribute of the <code class="idl"><a data-link-type="idl" href="browsers.html#window-window" id="ref-for-window-window-37">Window</a></code> interface
  must return the <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-15">Location</a></code> object for that <code class="idl"><a data-link-type="idl" href="browsers.html#window-window" id="ref-for-window-window-38">Window</a></code> object.</p>
    <p><code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-16">Location</a></code> objects provide a representation of the <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a> of the <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-72">active document</a> of their <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-212">browsing context</a>, and allow the <a data-link-type="dfn" href="browsers.html#current-entry" id="ref-for-current-entry-17">current entry</a> of the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-213">browsing context</a>’s session history to be changed, by adding or
  replacing entries in the <code class="idl"><a data-link-type="idl" href="browsers.html#dom-window-history" id="ref-for-dom-window-history-5">history</a></code> object.</p>
<pre class="idl highlight def" data-highlight="webidl">[<a class="nv idl-code" data-link-type="extended-attribute">Unforgeable</a>]
<span class="kt">interface</span> <dfn class="nv dfn-paneled idl-code" data-dfn-for="Location" data-dfn-type="interface" data-export="" id="location-location">Location</dfn> {
  <dfn class="kt" data-dfn-for="Location" data-dfn-type="dfn" data-lt="stringification behavior" data-noexport="" id="Location-stringification-behavior">stringifier<a class="self-link" href="browsers.html#Location-stringification-behavior"></a></dfn> <span class="kt">attribute</span> <span class="kt">USVString</span> <a class="nv idl-code" data-link-type="attribute" data-type="USVString" href="browsers.html#dom-location-href" id="ref-for-dom-location-href-3">href</a>;
  <span class="kt">readonly</span> <span class="kt">attribute</span> <span class="kt">USVString</span> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="USVString" href="browsers.html#dom-location-origin" id="ref-for-dom-location-origin-1">origin</a>;
  <span class="kt">attribute</span> <span class="kt">USVString</span> <a class="nv idl-code" data-link-type="attribute" data-type="USVString" href="browsers.html#dom-location-protocol" id="ref-for-dom-location-protocol-1">protocol</a>;
  <span class="kt">attribute</span> <span class="kt">USVString</span> <a class="nv idl-code" data-link-type="attribute" data-type="USVString" href="browsers.html#dom-location-host" id="ref-for-dom-location-host-1">host</a>;
  <span class="kt">attribute</span> <span class="kt">USVString</span> <a class="nv idl-code" data-link-type="attribute" data-type="USVString" href="browsers.html#dom-location-hostname" id="ref-for-dom-location-hostname-1">hostname</a>;
  <span class="kt">attribute</span> <span class="kt">USVString</span> <a class="nv idl-code" data-link-type="attribute" data-type="USVString" href="browsers.html#dom-location-port" id="ref-for-dom-location-port-1">port</a>;
  <span class="kt">attribute</span> <span class="kt">USVString</span> <a class="nv idl-code" data-link-type="attribute" data-type="USVString" href="browsers.html#dom-location-pathname" id="ref-for-dom-location-pathname-1">pathname</a>;
  <span class="kt">attribute</span> <span class="kt">USVString</span> <a class="nv idl-code" data-link-type="attribute" data-type="USVString" href="browsers.html#dom-location-search" id="ref-for-dom-location-search-1">search</a>;
  <span class="kt">attribute</span> <span class="kt">USVString</span> <a class="nv idl-code" data-link-type="attribute" data-type="USVString" href="browsers.html#dom-location-hash" id="ref-for-dom-location-hash-1">hash</a>;

  <span class="kt">void</span> <a class="nv idl-code" data-link-type="method" href="browsers.html#dom-location-assign" id="ref-for-dom-location-assign-1">assign</a>(<span class="kt">USVString</span> <dfn class="nv idl-code" data-dfn-for="Location/assign(url)" data-dfn-type="argument" data-export="" id="dom-location-assign-url-url">url<a class="self-link" href="browsers.html#dom-location-assign-url-url"></a></dfn>);
  <span class="kt">void</span> <a class="nv idl-code" data-link-type="method" href="browsers.html#dom-location-replace" id="ref-for-dom-location-replace-1">replace</a>(<span class="kt">USVString</span> <dfn class="nv idl-code" data-dfn-for="Location/replace(url)" data-dfn-type="argument" data-export="" id="dom-location-replace-url-url">url<a class="self-link" href="browsers.html#dom-location-replace-url-url"></a></dfn>);
  <span class="kt">void</span> <a class="nv idl-code" data-link-type="method" href="browsers.html#dom-location-reload" id="ref-for-dom-location-reload-1">reload</a>();

  [<a class="nv idl-code" data-link-type="extended-attribute">SameObject</a>] <span class="kt">readonly</span> <span class="kt">attribute</span> <span class="kt">USVString</span>[] <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="USVString[]" href="browsers.html#dom-location-ancestororigins" id="ref-for-dom-location-ancestororigins-1">ancestorOrigins</a>;
};
</pre>
    <dl class="domintro">
     <dt><var>location</var> . <code>toString()</code>
     </dt><dt><var>location</var> . <code class="idl"><a data-link-type="idl" href="browsers.html#dom-location-href" id="ref-for-dom-location-href-4">href</a></code>
     </dt><dd>
      Returns the <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-17">Location</a></code> object’s URL. 
      <p>Can be set, to navigate to the given URL.</p>
     </dd><dt><var>location</var> . <code class="idl"><a data-link-type="idl" href="browsers.html#dom-location-origin" id="ref-for-dom-location-origin-2">origin</a></code>
     </dt><dd>Returns the <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-18">Location</a></code> object’s URL’s origin.
     </dd><dt><var>location</var> . <code class="idl"><a data-link-type="idl" href="browsers.html#dom-location-protocol" id="ref-for-dom-location-protocol-2">protocol</a></code>
     </dt><dd>
      Returns the <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-19">Location</a></code> object’s URL’s scheme. 
      <p>Can be set, to navigate to the same URL with a changed scheme.</p>
     </dd><dt><var>location</var> . <code class="idl"><a data-link-type="idl" href="browsers.html#dom-location-host" id="ref-for-dom-location-host-2">host</a></code>
     </dt><dd>
      Returns the <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-20">Location</a></code> object’s URL’s host and port (if different from the default port
    for the scheme). 
      <p>Can be set, to navigate to the same URL with a changed host and port.</p>
     </dd><dt><var>location</var> . <code class="idl"><a data-link-type="idl" href="browsers.html#dom-location-hostname" id="ref-for-dom-location-hostname-2">hostname</a></code>
     </dt><dd>
      Returns the <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-21">Location</a></code> object’s URL’s host. 
      <p>Can be set, to navigate to the same URL with a changed host.</p>
     </dd><dt><var>location</var> . <code class="idl"><a data-link-type="idl" href="browsers.html#dom-location-port" id="ref-for-dom-location-port-2">port</a></code>
     </dt><dd>
      Returns the <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-22">Location</a></code> object’s URL’s port. 
      <p>Can be set, to navigate to the same URL with a changed port.</p>
     </dd><dt><var>location</var> . <code class="idl"><a data-link-type="idl" href="browsers.html#dom-location-pathname" id="ref-for-dom-location-pathname-2">pathname</a></code>
     </dt><dd>
      Returns the <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-23">Location</a></code> object’s URL’s path. 
      <p>Can be set, to navigate to the same URL with a changed path.</p>
     </dd><dt><var>location</var> . <code class="idl"><a data-link-type="idl" href="browsers.html#dom-location-search" id="ref-for-dom-location-search-2">search</a></code>
     </dt><dd>
      Returns the <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-24">Location</a></code> object’s URL’s query (includes leading "<code>?</code>" if
    non-empty). 
      <p>Can be set, to navigate to the same URL with a changed query (ignores leading "<code>?</code>").</p>
     </dd><dt><var>location</var> . <code class="idl"><a data-link-type="idl" href="browsers.html#dom-location-hash" id="ref-for-dom-location-hash-2">hash</a></code>
     </dt><dd>
      Returns the <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-25">Location</a></code> object’s URL’s fragment (includes leading "<code>#</code>" if
    non-empty). 
      <p>Can be set, to navigate to the same URL with a changed fragment (ignores leading
    "<code>#</code>").</p>
     </dd><dt><var>location</var> . {{Location/assign(<var>url</var>)}}
     </dt><dd>Navigates to the given URL.
     </dd><dt><var>location</var> . {{Location/replace(<var>url</var>)}}
     </dt><dd>Removes the current page from the session history and navigates to the given URL.
     </dd><dt><var>location</var> . <code class="idl"><a data-link-type="idl" href="browsers.html#dom-location-reload" id="ref-for-dom-location-reload-2">reload()</a></code>
     </dt><dd>Reloads the current page.
     </dd><dt><var>location</var> . <code class="idl"><a data-link-type="idl" href="browsers.html#dom-location-ancestororigins" id="ref-for-dom-location-ancestororigins-2">ancestorOrigins</a></code>
     </dt><dd>Returns an array whose values are the origins of the ancestor <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-214">browsing contexts</a>, from
    the <a data-link-type="dfn" href="browsers.html#parent-browsing-context" id="ref-for-parent-browsing-context-18">parent browsing context</a> to the <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-63">top-level browsing context</a>.
    </dd></dl>
    <p>A <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-26">Location</a></code> object has an associated <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="relevant-document">relevant <code>Document</code></dfn>, which is this <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-27">Location</a></code> object’s associated <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object’s <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-215">browsing context</a>’s <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-73">active document</a>.</p>
    <p>A <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-28">Location</a></code> object has an associated <dfn data-dfn-for="Location" data-dfn-type="dfn" data-noexport="" id="location-url">url<a class="self-link" href="browsers.html#location-url"></a></dfn>, which is this <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-29">Location</a></code> object’s <a data-link-type="dfn" href="browsers.html#relevant-document" id="ref-for-relevant-document-1">relevant <code>Document</code></a>’s <a data-link-type="dfn" href="https://www.w3.org/TR/dom/#concept-document-url">URL</a>.</p>
    <p>A <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-30">Location</a></code> object has an associated <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="ancestor-origins-array">ancestor origins array</dfn>. When a <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-31">Location</a></code> object is created, its <a data-link-type="dfn" href="browsers.html#ancestor-origins-array" id="ref-for-ancestor-origins-array-1">ancestor origins array</a> must be set to a array created from the list
  of strings that the following steps would produce:</p>
    <ol>
     <li data-md="">
      <p>Let <var>output</var> be an empty ordered list of strings.</p>
     </li><li data-md="">
      <p>Let <var>current</var> be the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-216">browsing context</a> of the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> with which the <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-32">Location</a></code> object is associated.</p>
     </li><li data-md="">
      <p><var>Loop</var>: If <var>current</var> has no <a data-link-type="dfn" href="browsers.html#parent-browsing-context" id="ref-for-parent-browsing-context-19">parent browsing context</a>, jump to
the step labeled <var>End</var>.</p>
     </li><li data-md="">
      <p>Let <var>current</var> be <var>current</var>’s <a data-link-type="dfn" href="browsers.html#parent-browsing-context" id="ref-for-parent-browsing-context-20">parent browsing context</a>.</p>
     </li><li data-md="">
      <p>Append the <a data-link-type="dfn" href="browsers.html#unicode-serialization" id="ref-for-unicode-serialization-3">Unicode serialization</a> of <var>current</var>’s <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-74">active document</a>’s <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-67">origin</a> to <var>output</var> as a new value.</p>
     </li><li data-md="">
      <p>Return to the step labeled <var>Loop</var>.</p>
     </li><li data-md="">
      <p><var>End</var>: Return <var>output</var>.</p>
    </li></ol>
    <p>A <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-33">Location</a></code> object has an associated <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="location-object-setter-navigate"><code>Location</code>-object-setter navigate</dfn> algorithm, which given a <var>url</var>, runs these steps:</p>
    <ol>
     <li data-md="">
      <p>If any of the following conditions are met, let <var>replacement flag</var> be unset;
  otherwise, let it be set:</p>
      <ul>
       <li data-md="">
        <p>This <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-34">Location</a></code> object’s <a data-link-type="dfn" href="browsers.html#relevant-document" id="ref-for-relevant-document-2">relevant <code>Document</code></a> has <a data-link-type="dfn" href="syntax.html#completely-loaded" id="ref-for-completely-loaded-7">completely loaded</a>, or</p>
       </li><li data-md="">
        <p>In the <a data-link-type="dfn" href="webappapis.html#tasks" id="ref-for-tasks-73">task</a> in which the algorithm is running, an <a data-link-type="dfn" href="editing.html#activation-behavior" id="ref-for-activation-behavior-50">activation behavior</a> is
 currently being processed whose <code>click</code> event was <a data-link-type="dfn" href="infrastructure.html#trusted" id="ref-for-trusted-17">trusted</a>, or</p>
       </li><li data-md="">
        <p>In the <a data-link-type="dfn" href="webappapis.html#tasks" id="ref-for-tasks-74">task</a> in which the algorithm is running, the event listener for a <a data-link-type="dfn" href="infrastructure.html#trusted" id="ref-for-trusted-18">trusted</a> <code>click</code> event is being handled.</p>
      </li></ul>
     </li><li data-md="">
      <p><a data-link-type="dfn" href="browsers.html#location-object-navigate" id="ref-for-location-object-navigate-1"><code>Location</code>-object navigate</a>, given <var>url</var> and <var>replacement flag</var>.</p>
    </li></ol>
    <p>To <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="location-object-navigate"><code>Location</code>-object navigate</dfn>, given a <var>url</var> and <var>replacement flag</var>, run these steps:</p>
    <ol>
     <li data-md="">
      <p>The <a data-link-type="dfn" href="browsers.html#source-browsing-context" id="ref-for-source-browsing-context-10">source browsing context</a> is the <a data-link-type="dfn" href="webappapis.html#responsible-browsing-context" id="ref-for-responsible-browsing-context-6">responsible browsing context</a> specified by the <a data-link-type="dfn" href="webappapis.html#incumbent-settings-object" id="ref-for-incumbent-settings-object-6">incumbent settings object</a>.</p>
     </li><li data-md="">
      <p><a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-55">Navigate</a> the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-217">browsing context</a> to <var>url</var>, with the <a data-link-type="dfn" href="browsers.html#exceptions-enabled-flag" id="ref-for-exceptions-enabled-flag-3">exceptions enabled flag</a> set. Rethrow any exceptions.</p>
      <p>If the <var>replacement flag</var> is set or the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-218">browsing context</a>’s <a data-link-type="dfn" href="browsers.html#session-history" id="ref-for-session-history-21">session history</a> contains only one <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>, and that was the <code>about:blank</code> <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> created when the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-219">browsing context</a> was created,
  then the navigation must be done with <a data-link-type="dfn" href="browsers.html#replacement-must-be-enabled" id="ref-for-replacement-must-be-enabled-13">replacement enabled</a>.</p>
    </li></ol>
    <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="Location" data-dfn-type="attribute" data-export="" id="dom-location-href"><code>href</code></dfn> attribute’s getter must return this <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-35">Location</a></code> object’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a>, serialized.</p>
    <p>The <code>href</code> attribute’s setter must run these steps:</p>
    <ol>
     <li>Let <var>newURL</var> be the <a data-link-type="dfn" href="infrastructure.html#resulting-url-string" id="ref-for-resulting-url-string-15">resulting URL string</a> of <a data-link-type="dfn" href="infrastructure.html#reparsed" id="ref-for-reparsed-38">parsing</a> the given value relative to the <a data-link-type="dfn" href="webappapis.html#entry-settings-object" id="ref-for-entry-settings-object-9">entry settings object</a>’s <a data-link-type="dfn" href="webappapis.html#api-base-url" id="ref-for-api-base-url-3">API base URL</a>.
     </li><li>If that aborted with an error, throw a <code>TypeError</code> exception.
     </li><li><a data-link-type="dfn" href="browsers.html#location-object-setter-navigate" id="ref-for-location-object-setter-navigate-1"><code>Location</code>-object-setter navigate</a> to <var>newURL</var>.
    </li></ol>
    <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="Location" data-dfn-type="attribute" data-export="" id="dom-location-origin"><code>origin</code></dfn> attribute’s getter must return
  the <a data-link-type="dfn" href="browsers.html#unicode-serialization" id="ref-for-unicode-serialization-4">Unicode serialization</a> of this <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-36">Location</a></code> object’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a>’s <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-68">origin</a>.</p>
    <p class="note" role="note">It returns the Unicode rather than the ASCII serialization for
  compatibility with <code>MessageEvent</code>. </p>
    <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="Location" data-dfn-type="attribute" data-export="" id="dom-location-protocol"><code>protocol</code></dfn> attribute’s getter must
  return this <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-37">Location</a></code> object’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-scheme">scheme</a>, followed by "<code>:</code>".</p>
    <p>The <code class="idl"><a data-link-type="idl" href="browsers.html#dom-location-protocol" id="ref-for-dom-location-protocol-3">protocol</a></code> attribute’s setter must run these
  steps:</p>
    <ol>
     <li>Let <var>copyURL</var> be a copy of this <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-38">Location</a></code> object’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a>.
     </li><li>Let <var>possibleFailure</var> be the result of <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-basic-url-parser">basic URL parsing</a> the given value, followed by "<code>:</code>", with <var>copyURL</var> as <var>url</var> and <a data-link-type="dfn" href="https://url.spec.whatwg.org/#scheme-start-state">scheme start state</a> as <var>state override</var>.
     </li><li>If <var>possibleFailure</var> is failure, throw a <code>TypeError</code> exception.
     </li><li>If <var>copyURL</var>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-scheme">scheme</a> is not "<code>http</code>" or "<code>https</code>", terminate these steps.
     </li><li><a data-link-type="dfn" href="browsers.html#location-object-setter-navigate" id="ref-for-location-object-setter-navigate-2"><code>Location</code>-object-setter navigate</a> to <var>copyURL</var>.
    </li></ol>
    <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="Location" data-dfn-type="attribute" data-export="" id="dom-location-host"><code>host</code></dfn> attribute’s getter must run these
  steps:</p>
    <ol>
     <li>Let <var>url</var> be this <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-39">Location</a></code> object’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a>.
     </li><li>If <var>url</var>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-host">host</a> is null, return the empty
    string.
     </li><li>If <var>url</var>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-port">port</a> is null, return <var>url</var>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-host">host</a>, serialized.
     </li><li>Return <var>url</var>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-host">host</a>, serialized, followed by "<code>:</code>" and <var>url</var>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-port">port</a>, serialized.
    </li></ol>
    <p>The <code>host</code> attribute’s setter must run these steps:</p>
    <ol>
     <li>Let <var>copyURL</var> be a copy of this <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-40">Location</a></code> object’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a>.
     </li><li>If <var>copyURL</var>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#non-relative-flag">non-relative flag</a> is set, terminate these
    steps.
     </li><li><a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-basic-url-parser">Basic URL parse</a> the given value, with <var>copyURL</var> as <var>url</var> and <a data-link-type="dfn" href="https://url.spec.whatwg.org/#host-state">host state</a> as <var>state
    override</var>.
     </li><li><a data-link-type="dfn" href="browsers.html#location-object-setter-navigate" id="ref-for-location-object-setter-navigate-3"><code>Location</code>-object-setter navigate</a> to <var>copyURL</var>.
    </li></ol>
    <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="Location" data-dfn-type="attribute" data-export="" id="dom-location-hostname"><code>hostname</code></dfn> attribute’s getter must
  run these steps:</p>
    <ol>
     <li>If this <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-41">Location</a></code> object’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-host">host</a> is null, return the empty string.
     </li><li>Return this <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-42">Location</a></code> object’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-host">host</a>, serialized.
    </li></ol>
    <p>The <code>hostname</code> attribute’s setter must run these
  steps:</p>
    <ol>
     <li>Let <var>copyURL</var> be a copy of this <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-43">Location</a></code> object’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a>.
     </li><li>If <var>copyURL</var>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#non-relative-flag">non-relative flag</a> is set, terminate these
    steps.
     </li><li><a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-parser">Basic URL parse</a> the given value, with <var>copyURL</var> as <var>url</var> and <a data-link-type="dfn" href="https://url.spec.whatwg.org/#hostname-state">hostname state</a> as <var>state
    override</var>.
     </li><li><a data-link-type="dfn" href="browsers.html#location-object-setter-navigate" id="ref-for-location-object-setter-navigate-4"><code>Location</code>-object-setter navigate</a> to <var>copyURL</var>.
    </li></ol>
    <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="Location" data-dfn-type="attribute" data-export="" id="dom-location-port"><code>port</code></dfn> attribute’s getter must run these
  steps:</p>
    <ol>
     <li>If this <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-44">Location</a></code> object’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-port">port</a> is null, return the empty string.
     </li><li>Return this <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-45">Location</a></code> object’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-port">port</a>, serialized.
    </li></ol>
    <p>The <code>port</code> attribute’s setter must run these steps:</p>
    <ol>
     <li>Let <var>copyURL</var> be a copy of this <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-46">Location</a></code> object’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a>.
     </li><li>If <var>copyURL</var>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-host">host</a> is null, <var>copyURL</var>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#non-relative-flag">non-relative flag</a> is set, or <var>copyURL</var>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-scheme">scheme</a> is "<code>file</code>", terminate these
    steps.
     </li><li><a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-parser">Basic URL parse</a> the given value, with <var>copyURL</var> as <var>url</var> and <a data-link-type="dfn" href="https://url.spec.whatwg.org/#port-state">port state</a> as <var>state
    override</var>.
     </li><li><a data-link-type="dfn" href="browsers.html#location-object-setter-navigate" id="ref-for-location-object-setter-navigate-5"><code>Location</code>-object-setter navigate</a> to <var>copyURL</var>.
    </li></ol>
    <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="Location" data-dfn-type="attribute" data-export="" id="dom-location-pathname"><code>pathname</code></dfn> attribute’s getter must
  run these steps:</p>
    <ol>
     <li>Let <var>url</var> be this <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-47">Location</a></code> object’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a>.
     </li><li>If <var>url</var>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#non-relative-flag">non-relative flag</a> is set, return the first string in <var>url</var>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-path">path</a>.
     </li><li>Return "<code>/</code>", followed by the strings in <var>url</var>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-path">path</a> (including empty strings), separated from each other by
    "<code>/</code>".
    </li></ol>
    <p>The <code>pathname</code> attribute’s setter must run these
  steps:</p>
    <ol>
     <li>Let <var>copyURL</var> be a copy of this <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-48">Location</a></code> object’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a>.
     </li><li>If <var>copyURL</var>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#non-relative-flag">non-relative flag</a> is set, terminate these
    steps.
     </li><li>Set <var>copyURL</var>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-path">path</a> to the empty
    list.
     </li><li><a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-parser">Basic URL parse</a> the given value, with <var>copyURL</var> as <var>url</var> and <a data-link-type="dfn" href="https://url.spec.whatwg.org/#path-start-state">path start state</a> as <var>state
    override</var>.
     </li><li><a data-link-type="dfn" href="browsers.html#location-object-setter-navigate" id="ref-for-location-object-setter-navigate-6"><code>Location</code>-object-setter navigate</a> to <var>copyURL</var>.
    </li></ol>
    <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="Location" data-dfn-type="attribute" data-export="" id="dom-location-search"><code>search</code></dfn> attribute’s getter must run
  these steps:</p>
    <ol>
     <li>If this <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-49">Location</a></code> object’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-query">query</a> is either null or the empty string, return the
    empty string.
     </li><li>Return "<code>?</code>", followed by this <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-50">Location</a></code> object’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-query">query</a>.
    </li></ol>
    <p>The <code>search</code> attribute’s setter must run these
  steps:</p>
    <ol>
     <li>Let <var>copyURL</var> be a copy of this <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-51">Location</a></code> object’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a>.
     </li><li>If the given value is the empty string, set <var>copyURL</var>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-query">query</a> to null. 
     </li><li>
       Otherwise, run these substeps: 
      <ol>
       <li>Let <var>input</var> be the given value with a single leading "<code>?</code>"
      removed, if any.
       </li><li>Set <var>copyURL</var>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-query">query</a> to the empty
      string.
       </li><li><a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-parser">Basic URL parse</a> <var>input</var>, with <var>copyURL</var> as <var>url</var> and <a data-link-type="dfn" href="https://url.spec.whatwg.org/#query-state">query state</a> as <var>state override</var>,
      and the <a data-link-type="dfn" href="browsers.html#relevant-document" id="ref-for-relevant-document-3">relevant <code>Document</code></a>’s <a data-link-type="dfn" href="https://www.w3.org/TR/dom/#concept-document-encoding">document’s character
      encoding</a> as <var>encoding override</var>.
      </li></ol>
     </li><li><a data-link-type="dfn" href="browsers.html#location-object-setter-navigate" id="ref-for-location-object-setter-navigate-7"><code>Location</code>-object-setter navigate</a> to <var>copyURL</var>.
    </li></ol>
    <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="Location" data-dfn-type="attribute" data-export="" id="dom-location-hash"><code>hash</code></dfn> attribute’s getter must run these
  steps:</p>
    <ol>
     <li>If this <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-52">Location</a></code> object’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-fragment">fragment</a> is either null or the empty string, return
    the empty string.
     </li><li>Return "<code>#</code>", followed by this <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-53">Location</a></code> object’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-fragment">fragment</a>.
    </li></ol>
    <p>The <code>hash</code> attribute’s setter must run these steps:</p>
    <ol>
     <li>Let <var>copyURL</var> be a copy of this <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-54">Location</a></code> object’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a>.
     </li><li>If <var>copyURL</var>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-scheme">scheme</a> is "<code>javascript</code>", terminate these steps.
     </li><li>If the given value is the empty string, set <var>copyURL</var>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-fragment">fragment</a> to null. 
     </li><li>
       Otherwise, run these substeps: 
      <ol>
       <li>Let <var>input</var> be the given value with a single leading "<code>#</code>"
      removed, if any.
       </li><li>Set <var>copyURL</var>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-fragment">fragment</a> to the
      empty string.
       </li><li><a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-parser">Basic URL parse</a> <var>input</var>, with <var>copyURL</var> as <var>url</var> and <a data-link-type="dfn" href="https://url.spec.whatwg.org/#fragment-state">fragment state</a> as <var>state
      override</var>.
      </li></ol>
     </li><li><a data-link-type="dfn" href="browsers.html#location-object-setter-navigate" id="ref-for-location-object-setter-navigate-8"><code>Location</code>-object-setter navigate</a> to <var>copyURL</var>.
    </li></ol>
    <hr>
    <p>When the <dfn class="dfn-paneled idl-code" data-dfn-for="Location" data-dfn-type="method" data-export="" data-lt="assign()|assign(url)" id="dom-location-assign"><code>assign(<var>url</var>)</code></dfn> method is invoked, the user agent must run the following steps:</p>
    <ol>
     <li>
      <p><a data-link-type="dfn" href="infrastructure.html#reparsed" id="ref-for-reparsed-39">Parse</a> <var>url</var>, relative to the <a data-link-type="dfn" href="webappapis.html#api-base-url" id="ref-for-api-base-url-4">API base URL</a> specified by the <a data-link-type="dfn" href="webappapis.html#entry-settings-object" id="ref-for-entry-settings-object-10">entry settings object</a> and let <var>parsedURL</var> be the <a data-link-type="dfn" href="infrastructure.html#resulting-url-string" id="ref-for-resulting-url-string-16">resulting URL string</a>.</p>
      <p>If this is not successful, throw a "<code class="idl"><a data-link-type="idl" href="http://www.ecma-international.org/ecma-262/6.0/#sec-native-error-types-used-in-this-standard-syntaxerror">SyntaxError</a></code>" <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/WebIDL-1/#idl-DOMException">DOMException</a></code> and abort these
    steps.</p>
     </li><li><a data-link-type="dfn" href="browsers.html#location-object-navigate" id="ref-for-location-object-navigate-2"><code>Location</code>-object navigate</a> to <var>parsedURL</var>.
    </li></ol>
    <p>When the <dfn class="dfn-paneled idl-code" data-dfn-for="Location" data-dfn-type="method" data-export="" data-lt="replace()|replace(url)" id="dom-location-replace"><code>replace(<var>url</var>)</code></dfn> method is invoked, the user agent must run the following steps:</p>
    <ol>
     <li>
      <p><a data-link-type="dfn" href="infrastructure.html#reparsed" id="ref-for-reparsed-40">Parse</a> <var>url</var>, relative to the <a data-link-type="dfn" href="webappapis.html#api-base-url" id="ref-for-api-base-url-5">API base URL</a> specified by the <a data-link-type="dfn" href="webappapis.html#entry-settings-object" id="ref-for-entry-settings-object-11">entry settings object</a> and let <var>parsedURL</var> be the <a data-link-type="dfn" href="infrastructure.html#resulting-url-string" id="ref-for-resulting-url-string-17">resulting URL string</a>.</p>
      <p>If this is not successful, throw a "<code class="idl"><a data-link-type="idl" href="http://www.ecma-international.org/ecma-262/6.0/#sec-native-error-types-used-in-this-standard-syntaxerror">SyntaxError</a></code>" <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/WebIDL-1/#idl-DOMException">DOMException</a></code> and abort these
    steps.</p>
     </li><li><a data-link-type="dfn" href="browsers.html#location-object-navigate" id="ref-for-location-object-navigate-3"><code>Location</code>-object navigate</a> to <var>parsedURL</var> with the <var>replacement flag</var> set.
    </li></ol>
    <p>When the <dfn class="dfn-paneled idl-code" data-dfn-for="Location" data-dfn-type="method" data-export="" id="dom-location-reload"><code>reload()</code></dfn> method is invoked, the
  user agent must run the appropriate steps from the following list:</p>
    <dl class="switch">
     <dt>If the currently executing <a data-link-type="dfn" href="webappapis.html#tasks" id="ref-for-tasks-75">task</a> is the dispatch of a <code>resize</code> event in response to the user resizing the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-220">browsing
    context</a>
     </dt><dd>Repaint the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-221">browsing context</a> and abort these steps.
     </dd><dt>If the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-222">browsing context</a>’s <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-75">active document</a> is <a data-link-type="dfn" href="semantics-embedded-content.html#iframe-iframe-srcdoc-document" id="ref-for-iframe-iframe-srcdoc-document-11">an <code>iframe</code> <code>srcdoc</code> document</a>
     </dt><dd><a data-link-type="dfn" href="semantics-embedded-content.html#reprocess-the-iframe-attributes" id="ref-for-reprocess-the-iframe-attributes-5">Reprocess the <code>iframe</code> attributes</a> of the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-223">browsing context</a>’s <a data-link-type="dfn" href="browsers.html#browsing-context-container" id="ref-for-browsing-context-container-30">browsing context
    container</a>.
     </dd><dt>If the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-224">browsing context</a>’s <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-76">active document</a> has its <a data-link-type="dfn" href="dom.html#reload-override-flag" id="ref-for-reload-override-flag-2">reload
    override flag</a> set
     </dt><dd>Perform <a data-link-type="dfn" href="dom.html#overridden-reload" id="ref-for-overridden-reload-2">an overridden reload</a>, with the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-225">browsing context</a> being
    navigated as the <a data-link-type="dfn" href="webappapis.html#responsible-browsing-context" id="ref-for-responsible-browsing-context-7">responsible browsing context</a>.
     </dd><dt>Otherwise
     </dt><dd><a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-56">Navigate</a> the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-226">browsing context</a> to the document’s <a data-link-type="dfn" href="https://www.w3.org/TR/dom/#concept-document-url">URL</a> with the <a data-link-type="dfn" href="browsers.html#exceptions-enabled-flag" id="ref-for-exceptions-enabled-flag-4">exceptions enabled flag</a> set and <a data-link-type="dfn" href="browsers.html#replacement-must-be-enabled" id="ref-for-replacement-must-be-enabled-14">replacement enabled</a>.
    The <a data-link-type="dfn" href="browsers.html#source-browsing-context" id="ref-for-source-browsing-context-11">source browsing context</a> must be the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-227">browsing context</a> being navigated. This is
    a <a data-link-type="dfn" href="browsers.html#reload-triggered-navigation" id="ref-for-reload-triggered-navigation-1">reload-triggered navigation</a>. Rethrow any exceptions.
    </dd></dl>
    <p>When a user requests that the <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-77">active document</a> of a <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-228">browsing context</a> be reloaded through a user interface element, the user agent should <a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-57">navigate</a> the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-229">browsing context</a> to the same resource as that <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>, with <a data-link-type="dfn" href="browsers.html#replacement-must-be-enabled" id="ref-for-replacement-must-be-enabled-15">replacement enabled</a>. In the case of non-idempotent
  methods (e.g., HTTP POST), the user agent should prompt the user to confirm the operation first,
  since otherwise transactions (e.g., purchases or database modifications) could be repeated. User
  agents may allow the user to explicitly override any caches when reloading. If <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-230">browsing
  context</a>’s <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-78">active document</a>’s <a data-link-type="dfn" href="dom.html#reload-override-flag" id="ref-for-reload-override-flag-3">reload override flag</a> is set, then the
  user agent may instead perform <a data-link-type="dfn" href="dom.html#overridden-reload" id="ref-for-overridden-reload-3">an overridden reload</a> rather than the navigation
  described in this paragraph (with the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-231">browsing context</a> being reloaded as the <a data-link-type="dfn" href="browsers.html#source-browsing-context" id="ref-for-source-browsing-context-12">source browsing context</a>).</p>
    <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="Location" data-dfn-type="attribute" data-export="" id="dom-location-ancestororigins"><code>ancestorOrigins</code></dfn> attribute’s getter must run
  these steps:</p>
    <ol>
     <li data-md="">
      <p>If this <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-55">Location</a></code> object’s <a data-link-type="dfn" href="browsers.html#relevant-document" id="ref-for-relevant-document-4">relevant <code>Document</code></a>’s <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-69">origin</a> is not <a data-link-type="dfn" href="browsers.html#same-origin-domain" id="ref-for-same-origin-domain-7">same origin-domain</a> with the <a data-link-type="dfn" href="webappapis.html#entry-settings-object" id="ref-for-entry-settings-object-12">entry settings object</a>’s <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-70">origin</a>, then throw a
  "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#securityerror">SecurityError</a></code>" <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/WebIDL-1/#idl-DOMException">DOMException</a></code>.</p>
     </li><li data-md="">
      <p>Otherwise, return this <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-56">Location</a></code> object’s <a data-link-type="dfn" href="browsers.html#ancestor-origins-array" id="ref-for-ancestor-origins-array-2">ancestor origins array</a>.</p>
    </li></ol>
    <p>The <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-57">Location</a></code> object requires additional logic beyond IDL for security purposes. The internal
  slot and internal methods <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-58">Location</a></code> objects must implement are defined below.</p>
    <p>Every <code class="idl"><a data-link-type="idl" href="browsers.html#location-location" id="ref-for-location-location-59">Location</a></code> object has a [[<dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="defaultproperties">DefaultProperties</dfn>]] internal slot representing its
  own properties at time of its creation.</p>
    <h3 class="heading settled" data-level="6.7" id="browsing-the-web"><span class="secno">6.7. </span><span class="content">Browsing the Web</span><a class="self-link" href="browsers.html#browsing-the-web"></a></h3>
    <div class="impl">
     <h4 class="heading settled" data-level="6.7.1" id="navigating-across-documents"><span class="secno">6.7.1. </span><span class="content">Navigating across documents</span><a class="self-link" href="browsers.html#navigating-across-documents"></a></h4>
     <p>Certain actions cause the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-232">browsing context</a> to <i>navigate</i> to
  a new resource. A user agent may provide various ways for the user to explicitly cause a browsing
  context to navigate, in addition to those defined in this specification.</p>
     <p class="example" id="example-47a177b1"><a class="self-link" href="browsers.html#example-47a177b1"></a> For example, <a data-link-type="dfn" href="links.html#follow-hyperlinks" id="ref-for-follow-hyperlinks-11">following a hyperlink</a>, <a href="sec-forms.html#forms-form-submission">§4.10.22 Form submission</a>, and the <code>window.open()</code> and <code>location.assign()</code> methods can all cause a browsing context to
  navigate. </p>
     <p class="note" role="note"> A <i>resource</i> has a URL, but that might not be the only information necessary
  to identify it. For example, a <a data-link-type="dfn" href="sec-forms.html#form-submission" id="ref-for-form-submission-17">form submission</a> that uses HTTP POST would also have the HTTP method
  and payload. Similarly, <a data-link-type="dfn" href="semantics-embedded-content.html#iframe-iframe-srcdoc-document" id="ref-for-iframe-iframe-srcdoc-document-12">an <code>iframe</code> <code>srcdoc</code> document</a> needs to know the data it is to use. </p>
     <p>Navigation always involves <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="source-browsing-context">source browsing context</dfn>, which is the browsing context which
  was responsible for starting the navigation.</p>
     <p>When a browsing context is <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="navigated|navigate|navigation|navigating|navigation algorithm|navigating a browsing context|processing model for navigating across documents" data-noexport="" id="navigated">navigated</dfn> to a new resource, the user
  agent must run the following steps:</p>
     <ol>
      <li>
       <p>If the <a data-link-type="dfn" href="browsers.html#source-browsing-context" id="ref-for-source-browsing-context-13">source browsing context</a> is not <a data-link-type="dfn" href="browsers.html#allowed-to-navigate" id="ref-for-allowed-to-navigate-2">allowed to navigate</a> the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-233">browsing context</a> being navigated, then abort these steps.</p>
       <p>If these steps are aborted here, the user agent may instead offer to open the new resource in
    a new <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-64">top-level browsing context</a> or in the <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-65">top-level browsing context</a> of the <a data-link-type="dfn" href="browsers.html#source-browsing-context" id="ref-for-source-browsing-context-14">source browsing context</a>, at the user’s option, in which case the user agent
    must <a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-58">navigate</a> that designated <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-66">top-level
    browsing context</a> to the new resource as if the user had requested it independently.</p>
       <p class="note" role="note"> Doing so, however, can be dangerous, as it means that the user is overriding the
    author’s explicit request to sandbox the content. </p>
       <p>If the <a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-59">navigate</a> algorithm was invoked optionally with an <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="exceptions-enabled-flag">exceptions enabled flag</dfn>, and it
    is aborted on this step, then in addition to aborting this algorithm, the user agent must also
    throw a "<code class="idl"><a data-link-type="idl" href="https://heycam.github.io/webidl/#securityerror">SecurityError</a></code>" <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/WebIDL-1/#idl-DOMException">DOMException</a></code>.</p>
      </li><li>If there is a preexisting attempt to navigate the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-234">browsing context</a>, and the <a data-link-type="dfn" href="browsers.html#source-browsing-context" id="ref-for-source-browsing-context-15">source browsing context</a> is the same as the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-235">browsing context</a> being
    navigated, and that attempt is currently running the <a data-link-type="dfn" href="browsers.html#unloaded" id="ref-for-unloaded-6">unload a document</a> algorithm,
    and the <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-71">origin</a> of the <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a> of the resource being loaded in
    that navigation is not the <a data-link-type="dfn" href="browsers.html#same-origin" id="ref-for-same-origin-19">same origin</a> as the <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-72">origin</a> of the <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a> of the resource being loaded in <em>this</em> navigation, then abort these
    steps without affecting the preexisting attempt to navigate the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-236">browsing context</a>.
      </li><li>If a <a data-link-type="dfn" href="webappapis.html#tasks" id="ref-for-tasks-76">task</a> queued by the <a data-link-type="dfn" href="browsers.html#explicitly-going-back-or-forwards-in-the-session-history" id="ref-for-explicitly-going-back-or-forwards-in-the-session-history-5">traverse the history by a
    delta</a> algorithm is running the <a data-link-type="dfn" href="browsers.html#unloaded" id="ref-for-unloaded-7">unload a document</a> algorithm for the <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-79">active document</a> of the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-237">browsing context</a> being navigated, then abort
    these steps without affecting the <a data-link-type="dfn" href="browsers.html#unloaded" id="ref-for-unloaded-8">unload a document</a> algorithm or the aforementioned
    history traversal task.
      </li><li>If the <a data-link-type="dfn" href="browsers.html#prompt-to-unload" id="ref-for-prompt-to-unload-3">prompt to unload a document</a> algorithm is being run for the <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-80">active document</a> of the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-238">browsing context</a> being navigated, then abort
    these steps without affecting the <a data-link-type="dfn" href="browsers.html#prompt-to-unload" id="ref-for-prompt-to-unload-4">prompt to unload a document</a> algorithm.
      </li><li>
       <p>Let <var>gone async</var> be false.</p>
       <p class="note" role="note"> The <i>handle redirects</i> step later in
    this algorithm can in certain cases jump back to the step labeled <a data-link-type="dfn" href="browsers.html#fragment-identifier" id="ref-for-fragment-identifier-2"><i>fragment identifiers</i></a>. Since, between those two steps,
    this algorithm goes from operating immediately in the context of the calling <a data-link-type="dfn" href="webappapis.html#tasks" id="ref-for-tasks-77">task</a> to operating <a data-link-type="dfn" href="infrastructure.html#in-parallel" id="ref-for-in-parallel-28">in parallel</a> independent of the <a data-link-type="dfn" href="webappapis.html#event-loop" id="ref-for-event-loop-34">event loop</a>, some of the intervening steps need to be able to handle both being run as part of a <a data-link-type="dfn" href="webappapis.html#tasks" id="ref-for-tasks-78">task</a> and
    running <a data-link-type="dfn" href="infrastructure.html#in-parallel" id="ref-for-in-parallel-29">in parallel</a>. The <var>gone async</var> flag is thus used to make these steps
    aware of which mode they are operating in. </p>
      </li><li><dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="the step labeled fragment identifiers" data-noexport="" id="the-step-labeled-fragment-identifiers"></dfn><i>Fragment identifiers</i>: If this is not a <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="reload-triggered-navigation">reload-triggered navigation</dfn>: apply the <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-parser">URL parser</a> algorithm to the <a data-link-type="dfn" href="https://url.spec.whatwg.org/#syntax-url-absolute">absolute URL</a> of the new resource and the <a data-link-type="dfn" href="dom.html#the-document-address" id="ref-for-the-document-address-18">address</a> of the <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-81">active document</a> of the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-239">browsing context</a> being navigated; if all the components of the resulting <a data-link-type="dfn" href="https://url.spec.whatwg.org/#url-parsing">parsed
    URLs</a>, ignoring any <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-fragment">fragment</a> components, are
    identical, and the new resource is to be fetched using <code>GET</code>, and the <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url">URL record</a> of the new resource has a <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-fragment">fragment</a> component that is not null (even if it is empty),
    then <a data-link-type="dfn" href="browsers.html#fragment-identifier" id="ref-for-fragment-identifier-3">navigate to that fragment identifier</a> and abort these
    steps.
      </li><li>If <var>gone async</var> is false, cancel any preexisting but not yet <a data-link-type="dfn" href="browsers.html#matured" id="ref-for-matured-2">mature</a> attempt to navigate the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-240">browsing
    context</a>, including canceling any instances of the <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-fetch">fetch</a> algorithm started by those attempts. If one of those attempts
    has already created and initialized a new <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object, <a data-link-type="dfn" href="browsers.html#abort-the-document" id="ref-for-abort-the-document-4">abort</a> that <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> also. (Navigation attempts that have <a data-link-type="dfn" href="browsers.html#matured" id="ref-for-matured-3">matured</a> already have session history entries, and are
    therefore handled during the <a data-link-type="dfn" href="browsers.html#updating-the-session-history-with-the-new-page" id="ref-for-updating-the-session-history-with-the-new-page-1">update the session history with the new page</a> algorithm,
    later.)
      </li><li>If the new resource is to be handled using a mechanism that does not affect the browsing
    context, e.g., ignoring the navigation request altogether because the specified scheme is not one
    of the supported protocols, then abort these steps and <a data-link-type="dfn" href="browsers.html#proceed-with-that-mechanism-instead" id="ref-for-proceed-with-that-mechanism-instead-1">proceed with that mechanism instead</a>.
      </li><li>
       <p>If <var>gone async</var> is false, <a data-link-type="dfn" href="browsers.html#prompt-to-unload" id="ref-for-prompt-to-unload-5">prompt
    to unload</a> the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object. If the user <a data-link-type="dfn" href="browsers.html#refused-to-allow-the-document-to-be-unloaded" id="ref-for-refused-to-allow-the-document-to-be-unloaded-3">refused to allow the
    document to be unloaded</a>, then abort these steps.</p>
       <p>If this instance of the <a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-60">navigation</a> algorithm gets canceled
    while this step is running, the <a data-link-type="dfn" href="browsers.html#prompt-to-unload" id="ref-for-prompt-to-unload-6">prompt to unload a document</a> algorithm must
    nonetheless be run to completion.</p>
      </li><li>If <var>gone async</var> is false, <a data-link-type="dfn" href="browsers.html#abort-the-document" id="ref-for-abort-the-document-5">abort</a> the <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-82">active document</a> of the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-241">browsing context</a>.
      </li><li>
       <p>If the new resource is to be handled by displaying some sort of inline content, e.g., an error
    message because the specified scheme is not one of the supported protocols, or an inline prompt
    to allow the user to select <a data-link-type="dfn" href="webappapis.html#a-registered-handler" id="ref-for-a-registered-handler-1">a registered
    handler</a> for the given scheme, then <a data-link-type="dfn" href="browsers.html#display-the-inline-content" id="ref-for-display-the-inline-content-1">display the inline
    content</a> and abort these steps.</p>
       <p class="note" role="note"> In the case of a registered handler being used, the algorithm will be reinvoked
    with a new URL to handle the request. </p>
      </li><li>
       <p>If the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-242">browsing context</a> being navigated is a <a data-link-type="dfn" href="browsers.html#nested-browsing-contexts" id="ref-for-nested-browsing-contexts-71">nested browsing context</a>, then put it in the <a data-link-type="dfn" href="browsers.html#delaying-load-events-mode" id="ref-for-delaying-load-events-mode-4">delaying <code>load</code> events
    mode</a>.</p>
       <p>The user agent must take this <a data-link-type="dfn" href="browsers.html#nested-browsing-contexts" id="ref-for-nested-browsing-contexts-72">nested browsing context</a> out of the <a data-link-type="dfn" href="browsers.html#delaying-load-events-mode" id="ref-for-delaying-load-events-mode-5">delaying <code>load</code> events mode</a> when this <a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-61">navigation</a> algorithm later matures, or when it terminates (whether due to having
    run all the steps, or being canceled, or being aborted), whichever happens first.</p>
      </li><li>
       <p>This is the step that attempts to obtain the resource, if necessary. Jump to the first
    appropriate substep:</p>
       <dl>
        <dt>If the resource has already been obtained (e.g., because it is being used to populate an <code><a data-link-type="element" href="semantics-embedded-content.html#elementdef-object" id="ref-for-elementdef-object-79">object</a></code> element’s new <a data-link-type="dfn" href="browsers.html#child-browsing-context" id="ref-for-child-browsing-context-23">child browsing context</a>)
        </dt><dd>Skip this step. The data is already available.
        </dd><dt>If the new resource is a <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a> whose <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-scheme">scheme</a> is <code>javascript</code>
        </dt><dd>
         <p><a data-link-type="dfn" href="webappapis.html#queuing" id="ref-for-queuing-118">Queue a task</a> to run <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="javascript: urls|javascript: url|dereferencing a javascript: url" data-noexport="" id="javascript-urls">these "<code>javascript:</code> URL" steps</dfn>,
      associated with the <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-83">active document</a> of the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-243">browsing context</a> being navigated:</p>
         <ol>
          <li data-md="">
           <p>If the <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-73">origin</a> of the <a data-link-type="dfn" href="browsers.html#source-browsing-context" id="ref-for-source-browsing-context-16">source browsing context</a> is not the <a data-link-type="dfn" href="browsers.html#same-origin" id="ref-for-same-origin-20">same origin</a> as
  the <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-74">origin</a> of the <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-84">active document</a> of the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-244">browsing context</a> being
  navigated, then let <var>result</var> be undefined, and jump to the step labeled <i>process results</i> below.</p>
          </li><li data-md="">
           <p>Let <var>urlRecord</var> be the result of running the <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-parser">URL parser</a> on the <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a> of the new resource.</p>
          </li><li data-md="">
           <p>Let <var>script source</var> be the empty string.</p>
          </li><li data-md="">
           <p>Append the first string of <var>urlRecord</var>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-path">path</a> component to <var>script
  source</var>.</p>
          </li><li data-md="">
           <p>If <var>urlRecord</var>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-query">query</a> component is not null, then first
  append a U+003F QUESTION MARK character (?) to <var>script source</var>, and then append <var>urlRecord</var>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-query">query</a> component to <var>script source</var>.</p>
          </li><li data-md="">
           <p>If <var>urlRecord</var>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-fragment">fragment</a> component is not null, then first
  append a U+0023 NUMBER SIGN character (#) to <var>script source</var>, and then append <var>urlRecord</var>’s <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-fragment">fragment</a> component to <var>script
  source</var>.</p>
          </li><li data-md="">
           <p>Replace <var>script source</var> with the result of applying the <a data-link-type="dfn" href="https://url.spec.whatwg.org/#percent-decode">percent decode</a> algorithm to <var>script source</var>.</p>
          </li><li data-md="">
           <p>Replace <var>script source</var> with the result of applying the <a data-link-type="dfn" href="infrastructure.html#utf-8-decode" id="ref-for-utf-8-decode-2">UTF-8 decode</a> algorithm to <var>script source</var>.</p>
          </li><li data-md="">
           <p>Let <var>address</var> be the <a data-link-type="dfn" href="dom.html#the-document-address" id="ref-for-the-document-address-19">address</a> of the <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-85">active document</a> of the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-245">browsing context</a> being navigated.</p>
          </li><li data-md="">
           <p>Let <var>settings</var> be the <a data-link-type="dfn" href="webappapis.html#relevant-settings-object" id="ref-for-relevant-settings-object-4">relevant settings object</a> of the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-246">browsing
   context</a> being navigated.</p>
          </li><li data-md="">
           <p>Let <var>script</var> be the result of <a data-link-type="dfn" href="webappapis.html#create-a-classic-script" id="ref-for-create-a-classic-script-2">creating a classic script</a> given <var>script source</var> and <var>settings</var>.</p>
          </li><li data-md="">
           <p>Let <var>result</var> be the result of <a data-link-type="dfn" href="webappapis.html#run-a-classic-script" id="ref-for-run-a-classic-script-2">running the classic script</a> <var>script</var>. If evaluation was unsuccessful, let <var>result</var> be undefined
   instead. (The result will also be undefined if <a data-link-type="dfn" href="webappapis.html#scripting-is-disabled" id="ref-for-scripting-is-disabled-12">scripting is disabled</a>.)</p>
          </li><li data-md="">
           <p><em>Process results</em>: If <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-ecmascript-data-types-and-values">Type</a>(<var>result</var>) is not <code>String</code>, then the result of obtaining the resource for the URL is a <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-response">response</a> whose <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-status">status</a> is <code>204</code>.</p>
           <p>Otherwise, the result of obtaining the resource for the URL is a <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-response">response</a> whose <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-response-header-list">header list</a> consists of <code>Content-Type</code>/<a href="iana.html#text-html"><code>text/html</code></a> and whose <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-response-body">body</a> is <var>result</var>, and whose <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-response-https-state">HTTPS state</a> is <var>settings</var>’s <a data-link-type="dfn" href="webappapis.html#settings-https-state" id="ref-for-settings-https-state-2">HTTPS state</a>.</p>
           <p>When it comes time to <a data-link-type="dfn" href="browsers.html#set-the-documents-address" id="ref-for-set-the-documents-address-2">set the document’s address</a> in the <a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-62">navigation algorithm</a>, use <var>address</var> as the <a data-link-type="dfn" href="browsers.html#override-url" id="ref-for-override-url-2">override URL</a>.</p>
         </li></ol>
         <p>The <a data-link-type="dfn" href="webappapis.html#task-source" id="ref-for-task-source-18">task source</a> for this <a data-link-type="dfn" href="webappapis.html#tasks" id="ref-for-tasks-79">task</a> is the <a data-link-type="dfn" href="webappapis.html#dom-manipulation-task-source" id="ref-for-dom-manipulation-task-source-13">DOM manipulation task source</a>.</p>
         <div class="example" id="example-1f6341c6"><a class="self-link" href="browsers.html#example-1f6341c6"></a> So for example a <a data-link-type="dfn" href="browsers.html#javascript-urls" id="ref-for-javascript-urls-2"><code>javascript:</code> URL</a> in
        an <code><a data-link-type="element-sub" href="links.html#element-attrdef-a-href" id="ref-for-element-attrdef-a-href-37">href</a></code> attribute of an <code><a data-link-type="element" href="textlevel-semantics.html#elementdef-a" id="ref-for-elementdef-a-96">a</a></code> element
        would only be evaluated when the link was followed, while such a URL in the <code>src</code> attribute of an <code><a data-link-type="element" href="semantics-embedded-content.html#elementdef-iframe" id="ref-for-elementdef-iframe-62">iframe</a></code> element would be
        evaluated in the context of the <code>iframe</code>’s own <a data-link-type="dfn" href="browsers.html#nested-browsing-contexts" id="ref-for-nested-browsing-contexts-73">nested browsing context</a> when the <code>iframe</code> is being set up; once evaluated, its return value
        (if it was not void) would replace that <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-247">browsing context</a>’s <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>, thus also
        changing the <code>Window</code> object of that <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-248">browsing context</a>. </div>
        </dd><dt>Otherwise
        </dt><dd>
         <ol>
          <li>Let <var>request</var> be the new resource.
          </li><li>If <var>request</var> is a URL, set <var>request</var> to a new <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request">request</a> whose <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a> is <var>request</var>.
          </li><li>Set <var>request</var>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-client">client</a> to the <a data-link-type="dfn" href="browsers.html#source-browsing-context" id="ref-for-source-browsing-context-17">source browsing context</a>’s <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-86">active document</a>’s <code>Window</code> object’s <a data-link-type="dfn" href="webappapis.html#environment-settings-object" id="ref-for-environment-settings-object-14">environment settings object</a>, <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-target-browsing-context">target browsing context</a> to the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-249">browsing context</a> being navigated, <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-destination">destination</a> to "<code>document</code>",
        mode to "<code>navigate</code>", <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-credentials-mode">credentials mode</a> to "<code>include</code>", <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-use-url-credentials-flag">use-URL-credentials flag</a>, and <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-redirect-mode">redirect mode</a> to "<code>manual</code>".
          </li><li>Set <var>request</var>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#omit-origin-header-flag">omit-<code>Origin</code>-header flag</a>. 
          </li><li>If <var>request</var>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-method">method</a> is not <code>GET</code>, or, if the <a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-63">navigation algorithm</a> was invoked as a result of the <a data-link-type="dfn" href="sec-forms.html#submit" id="ref-for-submit-10">form submission
        algorithm</a>, then if there is an <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-75">origin</a> of the <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-87">active document</a> of the <a data-link-type="dfn" href="browsers.html#source-browsing-context" id="ref-for-source-browsing-context-18">source browsing context</a>, unset <var>request</var>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#omit-origin-header-flag">omit-<code>Origin</code>-header flag</a>.
          </li><li>Otherwise, if the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-250">browsing context</a> being navigated is a <a data-link-type="dfn" href="browsers.html#child-browsing-context" id="ref-for-child-browsing-context-24">child
        browsing context</a>, and the <a data-link-type="dfn" href="browsers.html#browsing-context-container" id="ref-for-browsing-context-container-31">browsing context container</a> of the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-251">browsing context</a> being navigated has a <a data-link-type="dfn" href="browsers.html#browsing-context-scope-origin" id="ref-for-browsing-context-scope-origin-4">browsing context scope
        origin</a>, set <var>request</var>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-request-origin">origin</a> to that <a data-link-type="dfn" href="browsers.html#browsing-context-scope-origin" id="ref-for-browsing-context-scope-origin-5">browsing context scope origin</a> and unset <var>request</var>’s <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#omit-origin-header-flag">omit-<code>Origin</code>-header flag</a>.
          </li><li><a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-fetch">Fetch</a> <var>request</var>.
         </li></ol>
       </dd></dl>
      </li><li>
       <p>If <var>gone async</var> is false, return to whatever algorithm invoked the
    navigation steps and continue running these steps <a data-link-type="dfn" href="infrastructure.html#in-parallel" id="ref-for-in-parallel-30">in parallel</a>.</p>
      </li><li>Let <var>gone async</var> be true.
      </li><li>Wait for one or more bytes to be available or for the user agent to establish that the
    resource in question is empty. During this time, the user agent may allow the user to cancel this
    navigation attempt or start other navigation attempts.
      </li><li>
       <p><i>Handle redirects</i>: If fetching the resource results in a redirect, and either the <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a> of the target of the redirect has the <a data-link-type="dfn" href="browsers.html#same-origin" id="ref-for-same-origin-21">same origin</a> as the original
    resource, or the resource is being obtained using the POST method or a safe method (in HTTP
    terms), return to <a data-link-type="dfn" href="browsers.html#the-step-labeled-fragment-identifiers" id="ref-for-the-step-labeled-fragment-identifiers-1">the step labeled <i>fragment
    identifiers</i></a> with the new resource, except that if the <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a> of the target of
    the redirect does not have a fragment identifier and the <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a> of the resource that
    led to the redirect does, then the fragment identifier of the resource that led to the redirect
    must be propagated to the <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a> of the target of the redirect.</p>
       <p class="example" id="example-38812fe0"><a class="self-link" href="browsers.html#example-38812fe0"></a> So for instance, if the original URL was "<code>https://example.com/#!sample</code>" and "<code>https://example.com/</code>" is
    found to redirect to "<code>https://example.com/</code>", the URL of the new resource
    will be "<code>https://example.com/#!sample</code>". </p>
       <p>Otherwise, if fetching the resource results in a redirect but the <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a> of the
    target of the redirect does not have the <a data-link-type="dfn" href="browsers.html#same-origin" id="ref-for-same-origin-22">same origin</a> as the original resource and
    the resource is being obtained using a method that is neither the POST method nor a safe method
    (in HTTP terms), then abort these steps. The user agent may indicate to the user that the
    navigation has been aborted for security reasons.</p>
      </li><li>
       <p><i>Resource handling</i>: If the resource’s out-of-band metadata (e.g., HTTP headers), not
    counting any <a data-link-type="dfn" href="infrastructure.html#content-type-metadata" id="ref-for-content-type-metadata-33">type information</a> (such as the Content-Type HTTP
    header), requires some sort of processing that will not affect the browsing context, then
    perform that processing and abort these steps.</p>
       <div class="note" role="note">
         Such processing might be triggered by, amongst other things, the following: 
        <ul class="brief">
         <li>HTTP status codes (e.g., 204 No Content or 205 Reset Content)
         </li><li>Network errors (e.g., the network interface being unavailable)
         </li><li>Cryptographic protocol failures (e.g., an incorrect TLS certificate)
        </li></ul>
       </div>
       <p>Responses with HTTP <code>Content-Disposition</code> headers specifying the <code>attachment</code> disposition type must be handled <a data-link-type="dfn" href="links.html#as-a-download" id="ref-for-as-a-download-3">as a download</a>.</p>
       <p>HTTP 401 responses that do not include a challenge recognized by the user agent must be
    processed as if they had no challenge, e.g., rendering the entity body as if the response had
    been 200 OK.</p>
       <p>User agents may show the entity body of an HTTP 401 response even when the response does
    include a recognized challenge, with the option to login being included in a non-modal fashion,
    to enable the information provided by the server to be used by the user before authenticating.
    Similarly, user agents should allow the user to authenticate (in a non-modal fashion) against
    authentication challenges included in other responses such as HTTP 200 OK responses, effectively
    allowing resources to present HTTP login forms without requiring their use.</p>
      </li><li>Let <var>type</var> be the computed type of the resource.
      </li><li>
       If the user agent has been configured to process resources of the given <var>type</var> using some mechanism other than rendering the content in a <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-252">browsing
    context</a>, then skip this step. Otherwise, if the <var>type</var> is one of the
    following types, jump to the appropriate entry in the following list, and process the resource as
    described there: 
       <dl class="switch">
        <dt>an <a data-link-type="dfn" href="infrastructure.html#html-mime-type" id="ref-for-html-mime-type-2">HTML MIME type</a>
        </dt><dd>Follow the steps given in the <a data-link-type="dfn" href="infrastructure.html#html-document" id="ref-for-html-document-26">HTML document</a> section,
      and then, once they have completed, abort this <a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-64">navigate</a> algorithm.
        </dd><dt>an <a data-link-type="dfn" href="infrastructure.html#xml-mime-type" id="ref-for-xml-mime-type-7">XML MIME type</a> that is not an <a data-link-type="dfn" href="browsers.html#explicitly-supported-xml-type" id="ref-for-explicitly-supported-xml-type-1">explicitly supported XML
      type</a>
        </dt><dd>Follow the steps given in the <a data-link-type="dfn" href="infrastructure.html#xml-document" id="ref-for-xml-document-17">XML document</a> section. If
      that section determines that the content is <em>not</em> to be displayed as a generic XML
      document, then proceed to the next step in this overall set of steps. Otherwise, once the steps
      given in the <a data-link-type="dfn" href="infrastructure.html#xml-document" id="ref-for-xml-document-18">XML document</a> section have completed, abort this <a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-65">navigate</a> algorithm.
        </dd><dt>a <a data-link-type="dfn" href="semantics-scripting.html#javascript-mime-type" id="ref-for-javascript-mime-type-6">JavaScript MIME type</a>
        </dt><dt>a <a data-link-type="dfn" href="browsers.html#json-mime-type" id="ref-for-json-mime-type-1">JSON MIME type</a> that is not an <a data-link-type="dfn" href="browsers.html#explicitly-supported-json-type" id="ref-for-explicitly-supported-json-type-1">explicitly supported JSON type</a>
        </dt><dt>"<code>text/css</code>"
        </dt><dt>"<code>text/plain</code>"
        </dt><dt>"<code>text/vtt</code>"
        </dt><dd>Follow the steps given in the <a data-link-type="dfn" href="browsers.html#plain-text-file" id="ref-for-plain-text-file-1">plain text file</a> section,
      and then, once they have completed, abort this <a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-66">navigate</a> algorithm.
        </dd><dt>"<code>multipart/x-mixed-replace</code>"
        </dt><dd>Follow the steps given in the <a href="iana.html#multipart-x-mixed-replace">§12.2 multipart/x-mixed-replace</a> section, and then,
      once they have completed, abort this <a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-67">navigate</a> algorithm.
        </dd><dt>A supported image, video, or audio type
        </dt><dd>Follow the steps given in the <a data-link-type="dfn" href="https://drafts.csswg.org/cssom/#dom-stylesheet-media">media</a> section, and then,
      once they have completed, abort this <a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-68">navigate</a> algorithm.
        </dd><dt>A type that will use an external application to render the content in the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-253">browsing
      context</a>
        </dt><dd>Follow the steps given in the <a data-link-type="dfn" href="infrastructure.html#plugin" id="ref-for-plugin-60">plugin</a> section, and then,
      once they have completed, abort this <a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-69">navigate</a> algorithm.
       </dd></dl>
       <p>An <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="explicitly-supported-xml-type">explicitly supported XML type</dfn> is one for which the user agent is configured to
    use an external application to render the content (either a <a data-link-type="dfn" href="infrastructure.html#plugin" id="ref-for-plugin-61">plugin</a> rendering
    directly in the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-254">browsing context</a>, or a separate application), or one for which the
    user agent has dedicated processing rules (e.g., a Web browser with a built-in Atom feed viewer
    would be said to explicitly support the <code>application/atom+xml</code> MIME type), or one for
    which the user agent has a dedicated handler (e.g., one registered using <code>registerContentHandler()</code>).</p>
       <p>The term <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="json-mime-type">JSON MIME type</dfn> is used to refer to the <a data-link-type="dfn" href="infrastructure.html#mime-type" id="ref-for-mime-type-34">MIME
    types</a> <code>application/json</code>, <code>text/json</code>, and any <a data-link-type="dfn" href="infrastructure.html#mime-type" id="ref-for-mime-type-35">MIME
    type</a> whose subtype ends with the five characters "<code>+json</code>".</p>
       <p>An <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="explicitly-supported-json-type">explicitly supported JSON type</dfn> is one for which the user agent is configured to
    use an external application to render the content (either a <a data-link-type="dfn" href="infrastructure.html#plugin" id="ref-for-plugin-62">plugin</a> rendering
    directly in the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-255">browsing context</a>, or a separate application), or one for which the
    user agent has dedicated processing rules, or one for which the user agent has a dedicated
    handler (e.g., one registered using <code>registerContentHandler()</code>).</p>
       <p><dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="set the document’s address|setting the document’s address" data-noexport="" id="set-the-documents-address">Setting the document’s address</dfn>: If there is no <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="override-url">override URL</dfn>, then any <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> created by these steps must have its <a data-link-type="dfn" href="dom.html#the-document-address" id="ref-for-the-document-address-20">address</a> set to the <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a> that was
    originally to be fetched, ignoring any other data that was used to obtain the resource. However,
    if there <em>is</em> an <a data-link-type="dfn" href="browsers.html#override-url" id="ref-for-override-url-3">override URL</a>, then any <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> created by
    these steps must have its <a data-link-type="dfn" href="dom.html#the-document-address" id="ref-for-the-document-address-21">address</a> set to that <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a> instead.</p>
       <p class="note" role="note"> An <a data-link-type="dfn" href="browsers.html#override-url" id="ref-for-override-url-4">override URL</a> is set when <a data-link-type="dfn" href="browsers.html#javascript-urls" id="ref-for-javascript-urls-3">dereferencing a <code>javascript:</code> URL</a> and when
    performing <a data-link-type="dfn" href="dom.html#overridden-reload" id="ref-for-overridden-reload-4">an overridden reload</a>. </p>
       <p><dfn data-dfn-type="dfn" data-noexport="" id="initializing-a-new-document-object">Initializing a new <code>Document</code> object<a class="self-link" href="browsers.html#initializing-a-new-document-object"></a></dfn>: when a <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> is created as part
  of the above steps, the user agent will be required to additionally run the following algorithm
  after creating the new object:</p>
       <ol>
        <li data-md="">
         <p>If <var>browsingContext</var>’s only entry in its <a data-link-type="dfn" href="browsers.html#session-history" id="ref-for-session-history-22">session history</a> is the <a data-link-type="scheme" href="infrastructure.html#schemedef-about" id="ref-for-schemedef-about-7">about:blank</a> <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> that was added when <var>browsingContext</var> was <a data-link-type="dfn" href="browsers.html#creating-a-new-browsing-context" id="ref-for-creating-a-new-browsing-context-2">created</a>, and navigation is occurring with <a data-link-type="dfn" href="browsers.html#replacement-must-be-enabled" id="ref-for-replacement-must-be-enabled-16">replacement enabled</a>, and that <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> has the <a data-link-type="dfn" href="browsers.html#same-origin" id="ref-for-same-origin-23">same origin</a> as the new <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>, then</p>
         <ol>
          <li data-md="">
           <p>Let <var>window</var> be the <code class="idl"><a data-link-type="idl" href="browsers.html#window-window" id="ref-for-window-window-39">Window</a></code> object of that <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>.</p>
          </li><li data-md="">
           <p>Change the <code class="idl"><a data-link-type="idl" href="browsers.html#dom-window-document" id="ref-for-dom-window-document-2">document</a></code> attribute of <var>window</var> to point to the new <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>.</p>
         </li></ol>
        </li><li data-md="">
         <p>Otherwise,</p>
         <ol>
          <li data-md="">
           <p>Call the JavaScript <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-initializehostdefinedrealm">InitializeHostDefinedRealm</a>() abstract operation with the
  following customizations:</p>
           <ul>
            <li data-md="">
             <p>For the global object, create a new <code class="idl"><a data-link-type="idl" href="browsers.html#window-window" id="ref-for-window-window-40">Window</a></code> object <var>window</var>.</p>
            </li><li data-md="">
             <p>For the global <em>this</em> value, use <var>browsingContext</var>’s <code class="idl"><a data-link-type="idl" href="browsers.html#windowproxy" id="ref-for-windowproxy-33">WindowProxy</a></code> object.</p>
            </li><li data-md="">
             <p>Let <var>realm execution context</var> be the created <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#sec-execution-contexts">JavaScript execution context</a>.</p>
            </li><li data-md="">
             <p>Do not obtain any source texts for scripts.</p>
           </li></ul>
          </li><li data-md="">
           <p><a data-link-type="dfn" href="browsers.html#set-up-a-browsing-context-environment-settings-object" id="ref-for-set-up-a-browsing-context-environment-settings-object-2">Set up a browsing context environment settings object</a> with <var>realm execution context</var>, and let <var>settings object</var> be the result.</p>
          </li><li data-md="">
           <p>Set <var>window</var>’s <a data-link-type="dfn" href="browsers.html#document-associated-with-a-window" id="ref-for-document-associated-with-a-window-4">associated <code>Document</code></a> to the new <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>.</p>
         </li></ol>
        </li><li data-md="">
         <p>Set <var>browsingContext</var>’s <code class="idl"><a data-link-type="idl" href="browsers.html#windowproxy" id="ref-for-windowproxy-34">WindowProxy</a></code> object’s [[Window]] internal slot value to <var>window</var>.</p>
        </li><li data-md="">
         <p>Set the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <a data-link-type="dfn" href="dom.html#document-https-state" id="ref-for-document-https-state-4">HTTPS state</a> to the <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-response-https-state">HTTPS state</a> of the resource used to generate the document.</p>
        </li><li data-md="">
         <p>Execute the <a data-link-type="dfn" href="https://www.w3.org/TR/CSP3/#initialize-document-csp">Initialize a <code>Document</code>’s CSP list</a> algorithm on the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object and the resource used to generate the document. <a data-link-type="biblio" href="references.html#biblio-csp3">[CSP3]</a></p>
        </li><li data-md="">
         <p>Set <a data-link-type="dfn" href="dom.html#the-documents-referrer" id="ref-for-the-documents-referrer-2">the document’s referrer</a> to the <em>address of the resource from which Request-URIs are obtained</em> as determined when the
  fetch algorithm obtained the resource, if that algorithm was used and determined such a value;
  otherwise, set it to the empty string.</p>
        </li><li data-md="">
         <p><a data-link-type="dfn" href="browsers.html#implement-the-sandboxing" id="ref-for-implement-the-sandboxing-2">Implement the sandboxing</a> for the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>.</p>
        </li><li data-md="">
         <p>If the <a data-link-type="dfn" href="browsers.html#active-sandboxing-flag-set" id="ref-for-active-sandboxing-flag-set-19">active sandboxing flag set</a> of the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-256">browsing context</a> or any
  of its <a data-link-type="dfn" href="browsers.html#ancestor-browsing-context" id="ref-for-ancestor-browsing-context-10">ancestor browsing contexts</a> (if any) have the <a data-link-type="dfn" href="browsers.html#sandboxed-fullscreen-browsing-context-flag" id="ref-for-sandboxed-fullscreen-browsing-context-flag-2">sandboxed fullscreen browsing context flag</a> set, then skip this step.</p>
         <p>If the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-257">browsing context</a> has a <a data-link-type="dfn" href="browsers.html#browsing-context-container" id="ref-for-browsing-context-container-32">browsing context container</a> and
  either it is not an <code><a data-link-type="element" href="semantics-embedded-content.html#elementdef-iframe" id="ref-for-elementdef-iframe-63">iframe</a></code> element, or it does not have the <code>allowfullscreen</code> attribute specified, or its <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> does not have the <a data-link-type="dfn" href="https://fullscreen.spec.whatwg.org/#fullscreen-enabled-flag">fullscreen enabled flag</a> set,
  then also skip this step.</p>
         <p>Otherwise, set the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <a data-link-type="dfn" href="https://fullscreen.spec.whatwg.org/#fullscreen-enabled-flag">fullscreen enabled flag</a>.</p>
        </li><li>
         <p><i>Non-document content</i>: If, given <var>type</var>, the new resource is to be
handled by displaying some sort of inline content, e.g., a native rendering of the content, an
error message because the specified type is not supported, or an inline prompt to allow the user
to select <a data-link-type="dfn" href="webappapis.html#a-registered-handler" id="ref-for-a-registered-handler-2">a registered handler</a> for
the given type, then <a data-link-type="dfn" href="browsers.html#display-the-inline-content" id="ref-for-display-the-inline-content-2">display the inline content</a>, and
then abort these steps.</p>
         <p class="note" role="note"> In the case of a registered handler being used, the algorithm will be reinvoked
with a new URL to handle the request. </p>
        </li><li>Otherwise, the document’s <var>type</var> is such that the resource will not
affect the browsing context, e.g., because the resource is to be handed to an external application
or because it is an unknown type that will be processed <a data-link-type="dfn" href="links.html#as-a-download" id="ref-for-as-a-download-4">as a download</a>. <a data-link-type="dfn" href="browsers.html#proceed-with-that-mechanism-instead" id="ref-for-proceed-with-that-mechanism-instead-2">Process the resource appropriately</a>. 
       </li></ol>
     </li></ol>
     <p>When a resource is handled by <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="proceed with that mechanism instead|passing its URL or data to an external software package|process the resource appropriately" data-noexport="" id="proceed-with-that-mechanism-instead">passing its URL or data to an external software package</dfn> separate from the user agent (e.g., handing a <code>mailto:</code> URL to a mail client, or a Word document to a word
  processor), user agents should attempt to mitigate the risk that this is an attempt to exploit the
  target software, e.g., by prompting the user to confirm that the <a data-link-type="dfn" href="browsers.html#source-browsing-context" id="ref-for-source-browsing-context-19">source browsing
  context</a>’s <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-88">active document</a>’s <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-76">origin</a> is to be allowed to invoke the
  specified software. In particular, if the <a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-70">navigate</a> algorithm, when it was invoked,
  was not <a data-link-type="dfn" href="browsers.html#allowed-to-show-a-popup" id="ref-for-allowed-to-show-a-popup-6">allowed to show a popup</a>, the user agent should not invoke the external
  software package without prior user confirmation.</p>
     <p class="example" id="example-e92fcf25"><a class="self-link" href="browsers.html#example-e92fcf25"></a> For example, there could be a vulnerability in the target software’s URL
  handler which a hostile page would attempt to exploit by tricking a user into clicking a link. </p>
     <hr>
     <p>Some of the sections below, to which the above algorithm defers in certain cases, require the
  user agent to <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="updating the session history with the new page|update the session history with the new page" data-noexport="" id="updating-the-session-history-with-the-new-page">update the session history with the new page</dfn>. When a user agent is
  required to do this, it must <a data-link-type="dfn" href="webappapis.html#queuing" id="ref-for-queuing-119">queue a task</a> (associated with the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object of the <a data-link-type="dfn" href="browsers.html#current-entry" id="ref-for-current-entry-18">current entry</a>, not the new one) to run the following steps:</p>
     <ol>
      <li>
       <p><a data-link-type="dfn" href="browsers.html#unloaded" id="ref-for-unloaded-9">Unload</a> the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object of the <a data-link-type="dfn" href="browsers.html#current-entry" id="ref-for-current-entry-19">current entry</a>, with the <var>recycle</var> parameter set to false.</p>
       <p>If this instance of the <a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-71">navigation</a> algorithm is canceled while
    this step is running the <a data-link-type="dfn" href="browsers.html#unloaded" id="ref-for-unloaded-10">unload a document</a> algorithm, then the <a data-link-type="dfn" href="browsers.html#unloaded" id="ref-for-unloaded-11">unload a
    document</a> algorithm must be allowed to run to completion, but this instance of the <a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-72">navigation</a> algorithm must not run beyond this step. (In particular, for
    instance, the cancelation of this algorithm does not abort any event dispatch or script
    execution occurring as part of unloading the document or its descendants.)</p>
      </li><li>
       <dl>
        <dt>If the navigation was initiated for <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="entry-update">entry update</dfn> of an entry
        </dt><dd>
         <ol>
          <li>Replace the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> of the entry being updated, and any other entries
        that referenced the same document as that entry, with the new <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>.
          </li><li><a data-link-type="dfn" href="browsers.html#traverse-the-history" id="ref-for-traverse-the-history-5">Traverse the history</a> to the new entry.
         </li></ol>
         <p class="note" role="note"> This can only happen if the entry being updated is not the <a data-link-type="dfn" href="browsers.html#current-entry" id="ref-for-current-entry-20">current
      entry</a>, and can never happen with <a data-link-type="dfn" href="browsers.html#replacement-must-be-enabled" id="ref-for-replacement-must-be-enabled-17">replacement enabled</a>. (It happens when the
      user tried to traverse to a session history entry that no longer had a <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object.) </p>
        </dd><dt>Otherwise
        </dt><dd>
         <ol>
          <li>
           <p>Remove all the entries in the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-258">browsing context</a>’s <a data-link-type="dfn" href="browsers.html#session-history" id="ref-for-session-history-23">session
        history</a> after the <a data-link-type="dfn" href="browsers.html#current-entry" id="ref-for-current-entry-21">current entry</a>. If the <a data-link-type="dfn" href="browsers.html#current-entry" id="ref-for-current-entry-22">current entry</a> is
        the last entry in the session history, then no entries are removed.</p>
           <p class="note" role="note"> This <a data-link-type="dfn" href="browsers.html#doesnt-necessarily-have-to-affect" id="ref-for-doesnt-necessarily-have-to-affect-2">doesn’t necessarily have to affect</a> the
        user agent’s user interface. </p>
          </li><li>Append a new entry at the end of the <code>History</code> object representing the new
        resource and its <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object, related state, and the default <a data-link-type="dfn" href="browsers.html#scroll-restoration-mode" id="ref-for-scroll-restoration-mode-9">scroll
       restoration mode</a> of "<code>auto</code>".
          </li><li><a data-link-type="dfn" href="browsers.html#traverse-the-history" id="ref-for-traverse-the-history-6">Traverse the history</a> to the new entry. If the navigation was initiated
        with <a data-link-type="dfn" href="browsers.html#replacement-must-be-enabled" id="ref-for-replacement-must-be-enabled-18">replacement enabled</a>, then the traversal must itself be initiated with <a data-link-type="dfn" href="browsers.html#replacement-must-be-enabled" id="ref-for-replacement-must-be-enabled-19">replacement enabled</a>. 
         </li></ol>
       </dd></dl>
      </li><li>The <a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-73">navigation algorithm</a> has now <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="matured">matured</dfn>.
      </li><li><i>Fragment identifier loop</i>: <a data-link-type="dfn" href="webappapis.html#spinning-the-event-loop" id="ref-for-spinning-the-event-loop-1">Spin the event loop</a> for a user-agent-defined
    amount of time, as desired by the user agent implementor. (This is intended to allow the user
    agent to optimize the user experience in the face of performance concerns.)
      </li><li>If the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object has no parser, or its parser has <a data-link-type="dfn" href="syntax.html#stopped" id="ref-for-stopped-4">stopped parsing</a>, or the user agent has reason to believe the user is no longer
    interested in scrolling to the fragment identifier, then abort these steps.
      </li><li><a data-link-type="dfn" href="browsers.html#scroll-to-the-fragment-identifier" id="ref-for-scroll-to-the-fragment-identifier-1">Scroll to the fragment identifier</a> given in <a data-link-type="dfn" href="dom.html#the-document-address" id="ref-for-the-document-address-22">the document’s
    address</a>. If this fails to find <a data-link-type="dfn" href="browsers.html#an-indicated-part-of-the-document" id="ref-for-an-indicated-part-of-the-document-1">an
    indicated part of the document</a>, then return to the <i>fragment identifier loop</i> step.
     </li></ol>
     <p>The <a data-link-type="dfn" href="webappapis.html#task-source" id="ref-for-task-source-19">task source</a> for this <a data-link-type="dfn" href="webappapis.html#tasks" id="ref-for-tasks-80">task</a> is the <a data-link-type="dfn" href="webappapis.html#networking-task-source" id="ref-for-networking-task-source-23">networking task source</a>.</p>
     <h4 class="heading settled" data-level="6.7.2" id="page-load-processing-model-for-html-files"><span class="secno">6.7.2. </span><span class="content">Page load processing model for HTML files</span><a class="self-link" href="browsers.html#page-load-processing-model-for-html-files"></a></h4>
     <p>When an HTML document is to be loaded in a <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-259">browsing context</a>, the user agent must <a data-link-type="dfn" href="webappapis.html#queuing" id="ref-for-queuing-120">queue a task</a> to create a <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object, mark it as being an <a data-link-type="dfn" href="infrastructure.html#html-document" id="ref-for-html-document-27">HTML document</a>, set its <a data-link-type="dfn" href="https://www.w3.org/TR/dom/#concept-document-content-type">content type</a> to "<a href="iana.html#text-html"><code>text/html</code></a>",
  initialize the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object, and finally create an <a data-link-type="dfn" href="syntax.html#html-parser" id="ref-for-html-parser-25">HTML
  parser</a> and associate it with the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>. Each <a data-link-type="dfn" href="webappapis.html#tasks" id="ref-for-tasks-81">task</a> that the <a data-link-type="dfn" href="webappapis.html#networking-task-source" id="ref-for-networking-task-source-24">networking task source</a> places on the <a data-link-type="dfn" href="webappapis.html#task-queues" id="ref-for-task-queues-3">task queue</a> while fetching runs must then fill the parser’s <a data-link-type="dfn" href="syntax.html#input-byte-stream" id="ref-for-input-byte-stream-1">input byte
  stream</a> with the fetched bytes and cause the <a data-link-type="dfn" href="syntax.html#html-parser" id="ref-for-html-parser-26">HTML parser</a> to perform the
  appropriate processing of the input stream.</p>
     <p class="note" role="note"> The <a data-link-type="dfn" href="syntax.html#input-byte-stream" id="ref-for-input-byte-stream-2">input byte stream</a> converts bytes into characters for use in the <a data-link-type="dfn" href="syntax.html#tokenizer" id="ref-for-tokenizer-1">tokenizer</a>. This process relies, in part, on character encoding
  information found in the real <a data-link-type="dfn" href="infrastructure.html#content-type-metadata" id="ref-for-content-type-metadata-34">Content-Type metadata</a> of the
  resource; the "computed type" is not used for this purpose. </p>
     <p>When no more bytes are available, the user agent must <a data-link-type="dfn" href="webappapis.html#queuing" id="ref-for-queuing-121">queue a task</a> for the parser
  to process the implied EOF character, which eventually causes a <code>load</code> event to be fired.</p>
     <p>After creating the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object, but before any script execution, certainly
  before the parser <a data-link-type="dfn" href="syntax.html#stopped" id="ref-for-stopped-5">stops</a>, the user agent must <a data-link-type="dfn" href="browsers.html#updating-the-session-history-with-the-new-page" id="ref-for-updating-the-session-history-with-the-new-page-2">update the
  session history with the new page</a>.</p>
     <p>The <a data-link-type="dfn" href="webappapis.html#task-source" id="ref-for-task-source-20">task source</a> for the two tasks mentioned in this section must be the <a data-link-type="dfn" href="webappapis.html#networking-task-source" id="ref-for-networking-task-source-25">networking task source</a>.</p>
     <h4 class="heading settled" data-level="6.7.3" id="page-load-processing-model-for-xml-files"><span class="secno">6.7.3. </span><span class="content">Page load processing model for XML files</span><a class="self-link" href="browsers.html#page-load-processing-model-for-xml-files"></a></h4>
     <p>When faced with displaying an XML file inline, user agents must follow the requirements defined
  in the XML and Namespaces in XML recommendations, RFC 7303, DOM, and other relevant specifications
  to create a <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object and a corresponding <a data-link-type="dfn" href="xhtml.html#xml-parser" id="ref-for-xml-parser-19">XML parser</a>. <a data-link-type="biblio" href="references.html#biblio-xml">[XML]</a> <a data-link-type="biblio" href="references.html#biblio-xml-names">[XML-NAMES]</a> <a data-link-type="biblio" href="references.html#biblio-rfc7303">[RFC7303]</a> <a data-link-type="biblio" href="references.html#biblio-dom">[DOM]</a></p>
     <p class="note" role="note"> At the time of writing, the XML specification community had not actually yet
  specified how XML and the DOM interact. </p>
     <p>After the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> is created, the user agent must initialize the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object.</p>
     <p>The actual HTTP headers and other metadata, not the headers as mutated or implied by the
  algorithms given in this specification, are the ones that must be used when determining the
  character encoding according to the rules given in the above specifications. Once the character
  encoding is established, the <a data-link-type="dfn" href="https://www.w3.org/TR/dom/#concept-document-encoding">document’s character encoding</a> must be set to that
  character encoding.</p>
     <p>User agents may examine the namespace of the root <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#interface-element">Element</a></code> node of this <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object to perform namespace-based dispatch to alternative processing tools,
  e.g., determining that the content is actually a syndication feed and passing it to a feed handler.
  If such processing is to take place, abort the steps in this section, and jump to the next step (labeled <i>non-document content</i>) in the <a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-74">navigate</a> steps above.</p>
     <p>Otherwise, then, with the newly created <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>, the user agent must <a data-link-type="dfn" href="browsers.html#updating-the-session-history-with-the-new-page" id="ref-for-updating-the-session-history-with-the-new-page-3">update
  the session history with the new page</a>. User agents may do this before the complete document
  has been parsed (thus achieving <i>incremental rendering</i>), and must do this before any scripts
  are to be executed.</p>
     <p>Error messages from the parse process (e.g., XML namespace well-formedness errors) may be
  reported inline by mutating the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>.</p>
     <h4 class="heading settled" data-level="6.7.4" id="page-load-processing-model-for-text-files"><span class="secno">6.7.4. </span><span class="content"><dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="plain text file" data-noexport="" id="plain-text-file">Page load processing model for text files</dfn></span><a class="self-link" href="browsers.html#page-load-processing-model-for-text-files"></a></h4>
     <p>When a plain text document is to be loaded in a <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-260">browsing context</a>, the user agent
  must <a data-link-type="dfn" href="webappapis.html#queuing" id="ref-for-queuing-122">queue a task</a> to create a <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object, mark it as being an <a data-link-type="dfn" href="infrastructure.html#html-document" id="ref-for-html-document-28">HTML document</a>, set its <a data-link-type="dfn" href="https://www.w3.org/TR/dom/#concept-document-content-type">content type</a> to the <a data-link-type="dfn" href="infrastructure.html#computed-type-of-the-resource" id="ref-for-computed-type-of-the-resource-4">computed MIME type</a> of the
  resource (<var>type</var> in the <a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-75">navigate</a> algorithm), initialize the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object, create an <a data-link-type="dfn" href="syntax.html#html-parser" id="ref-for-html-parser-27">HTML parser</a>, associate it with the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>, act as if the tokenizer had emitted a start tag token with the tag name
  "pre" followed by a single U+000A LINE FEED (LF) character, and switch the <a data-link-type="dfn" href="syntax.html#html-parser" id="ref-for-html-parser-28">HTML parser</a>’s
  tokenizer to the <a href="syntax.html#plaintext-state">§8.2.4.7 PLAINTEXT state</a>. Each <a data-link-type="dfn" href="webappapis.html#tasks" id="ref-for-tasks-82">task</a> that
  the <a data-link-type="dfn" href="webappapis.html#networking-task-source" id="ref-for-networking-task-source-26">networking task source</a> places on the <a data-link-type="dfn" href="webappapis.html#task-queues" id="ref-for-task-queues-4">task queue</a> while fetching runs
  must then fill the parser’s <a data-link-type="dfn" href="syntax.html#input-byte-stream" id="ref-for-input-byte-stream-3">input byte stream</a> with the fetched bytes and cause the <a data-link-type="dfn" href="syntax.html#html-parser" id="ref-for-html-parser-29">HTML parser</a> to perform the appropriate processing of the input stream.</p>
     <p>The rules for how to convert the bytes of the plain text document into actual characters, and
  the rules for actually rendering the text to the user, are defined by the specifications for the <a data-link-type="dfn" href="infrastructure.html#computed-type-of-the-resource" id="ref-for-computed-type-of-the-resource-5">computed MIME type</a> of the resource (<var>type</var> in the <a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-76">navigate</a> algorithm).</p>
     <p>The <a data-link-type="dfn" href="https://www.w3.org/TR/dom/#concept-document-encoding">document’s character encoding</a> must be set to the character encoding used to
  decode the document.</p>
     <p>When no more bytes are available, the user agent must <a data-link-type="dfn" href="webappapis.html#queuing" id="ref-for-queuing-123">queue a task</a> for the parser
  to process the implied EOF character, which eventually causes a <code>load</code> event to be fired.</p>
     <p>After creating the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object, but potentially before the page has finished
  parsing, the user agent must <a data-link-type="dfn" href="browsers.html#updating-the-session-history-with-the-new-page" id="ref-for-updating-the-session-history-with-the-new-page-4">update the session history with the new page</a>.</p>
     <p>User agents may add content to the <code><a data-link-type="element" href="document-metadata.html#elementdef-head" id="ref-for-elementdef-head-43">head</a></code> element of the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>, e.g.,
  to link to a style sheet, provide a script, give the document a <a data-link-type="element" href="document-metadata.html#elementdef-title" id="ref-for-elementdef-title-27"><code>title</code></a>, etc.</p>
     <p class="note" role="note"> In particular, if the user agent supports the <code>Format=Flowed</code> feature of RFC3676 then the user agent would need to apply extra styling to cause the text to
  wrap correctly and to handle the quoting feature. <a data-link-type="biblio" href="references.html#biblio-rfc3676">[RFC3676]</a> </p>
     <p>The <a data-link-type="dfn" href="webappapis.html#task-source" id="ref-for-task-source-21">task source</a> for the two tasks mentioned in this section must be the <a data-link-type="dfn" href="webappapis.html#networking-task-source" id="ref-for-networking-task-source-27">networking task source</a>.</p>
     <h4 class="heading settled" data-level="6.7.5" id="page-load-processing-model-for-multipartx-mixed-replace-resources"><span class="secno">6.7.5. </span><span class="content">Page load processing model for <code>multipart/x-mixed-replace</code> resources</span><a class="self-link" href="browsers.html#page-load-processing-model-for-multipartx-mixed-replace-resources"></a></h4>
     <p>When a resource with the type <code>multipart/x-mixed-replace</code> is to be loaded in a <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-261">browsing context</a>, the user agent must parse the resource using the rules for
  multipart types. <a data-link-type="biblio" href="references.html#biblio-rfc2046">[RFC2046]</a></p>
     <p>For each body part obtained from the resource, the user agent must run a new instance of the <a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-77">navigate</a> algorithm, starting from the <i>resource handling</i> step, using the new
  body part as the resource being navigated, with <a data-link-type="dfn" href="browsers.html#replacement-must-be-enabled" id="ref-for-replacement-must-be-enabled-20">replacement enabled</a> if a previous
  body part from the same resource resulted in a <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object being created and <a data-link-type="dfn" href="https://www.w3.org/TR/dom/#concept-event-initialize">initialized</a>, and otherwise using the same
  setup as the <a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-78">navigate</a> attempt that caused this section to be invoked in the first
  place.</p>
     <p>For the purposes of algorithms processing these body parts as if they were complete stand-alone
  resources, the user agent must act as if there were no more bytes for those resources whenever the
  boundary following the body part is reached.</p>
     <p class="note" role="note"> Thus, <code>load</code> events (and for that matter <code>unload</code> events) do fire for each body part loaded. </p>
     <h4 class="heading settled" data-level="6.7.6" id="page-load-processing-model-for-media"><span class="secno">6.7.6. </span><span class="content">Page load processing model for media</span><a class="self-link" href="browsers.html#page-load-processing-model-for-media"></a></h4>
     <p>When an image, video, or audio resource is to be loaded in a <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-262">browsing context</a>, the
  user agent should create a <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object, mark it as being an <a data-link-type="dfn" href="infrastructure.html#html-document" id="ref-for-html-document-29">HTML document</a>, set its <a data-link-type="dfn" href="https://www.w3.org/TR/dom/#concept-document-content-type">content
  type</a> to the <a data-link-type="dfn" href="infrastructure.html#computed-type-of-the-resource" id="ref-for-computed-type-of-the-resource-6">computed MIME type</a> of the resource (<var>type</var> in the <a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-79">navigate</a> algorithm), initialize the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object, append
  an <code><a data-link-type="element" href="semantics.html#elementdef-html" id="ref-for-elementdef-html-27">html</a></code> element to the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>, append a <code><a data-link-type="element" href="document-metadata.html#elementdef-head" id="ref-for-elementdef-head-44">head</a></code> element and
  a <code><a data-link-type="element" href="sections.html#elementdef-body" id="ref-for-elementdef-body-58">body</a></code> element to the <code><a data-link-type="element" href="semantics.html#elementdef-html" id="ref-for-elementdef-html-28">html</a></code> element, append an element <var>host element</var> for the media, as described below, to the <code><a data-link-type="element" href="sections.html#elementdef-body" id="ref-for-elementdef-body-59">body</a></code> element,
  and set the appropriate attribute of the element <var>host element</var>, as described
  below, to the address of the image, video, or audio resource.</p>
     <p>The element <var>host element</var> to create for the media is the element given in
  the table below in the second cell of the row whose first cell describes the media. The
  appropriate attribute to set is the one given by the third cell in that same row.</p>
     <table>
      <thead>
       <tr>
        <th> Type of media 
        </th><th> Element for the media 
        </th><th> Appropriate attribute 
       </th></tr><tr>
        <td> Image 
        </td><td> <code>img</code> 
        </td><td> <code>src</code> 
       </td></tr><tr>
        <td> Video 
        </td><td> <code>video</code> 
        </td><td> <code>src</code> 
       </td></tr><tr>
        <td> Audio 
        </td><td> <code>audio</code> 
        </td><td> <code>src</code> 
     </td></tr></thead></table>
     <p>Then, the user agent must act as if it had <a data-link-type="dfn" href="syntax.html#stopped" id="ref-for-stopped-6">stopped
  parsing</a>.</p>
     <p>After creating the <code>Document</code> object, but potentially before the page has finished
  fully loading, the user agent must <a data-link-type="dfn" href="browsers.html#updating-the-session-history-with-the-new-page" id="ref-for-updating-the-session-history-with-the-new-page-5">update the session history with the new page</a>.</p>
     <p>User agents may add content to the <code><a data-link-type="element" href="document-metadata.html#elementdef-head" id="ref-for-elementdef-head-45">head</a></code> element of the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>, or
  attributes to the element <var>host element</var>, e.g., to link to a style sheet, provide a script, give the document a <a data-link-type="element" href="document-metadata.html#elementdef-title" id="ref-for-elementdef-title-28"><code>title</code></a>, make the media <a data-link-type="element-attr" href="semantics-embedded-content.html#element-attrdef-media-autoplay" id="ref-for-element-attrdef-media-autoplay-2">autoplay</a>, etc.</p>
     <h4 class="heading settled" data-level="6.7.7" id="page-load-processing-model-for-content-that-uses-plugins"><span class="secno">6.7.7. </span><span class="content">Page load processing model for content that uses plugins</span><a class="self-link" href="browsers.html#page-load-processing-model-for-content-that-uses-plugins"></a></h4>
     <p>When a resource that requires an external resource to be rendered is to be loaded in a <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-263">browsing context</a>, the user agent should create a <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object, mark
  it as being an <a data-link-type="dfn" href="infrastructure.html#html-document" id="ref-for-html-document-30">HTML document</a> and mark it as being a <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="plugin-document">plugin document</dfn>, set its <a data-link-type="dfn" href="https://www.w3.org/TR/dom/#concept-document-content-type">content
  type</a> to the <a data-link-type="dfn" href="infrastructure.html#computed-type-of-the-resource" id="ref-for-computed-type-of-the-resource-7">computed MIME type</a> of the resource (<var>type</var> in the <a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-80">navigate</a> algorithm), initialize the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object, append
  an <code><a data-link-type="element" href="semantics.html#elementdef-html" id="ref-for-elementdef-html-29">html</a></code> element to the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>, append a <code><a data-link-type="element" href="document-metadata.html#elementdef-head" id="ref-for-elementdef-head-46">head</a></code> element and
  a <code><a data-link-type="element" href="sections.html#elementdef-body" id="ref-for-elementdef-body-60">body</a></code> element to the <code><a data-link-type="element" href="semantics.html#elementdef-html" id="ref-for-elementdef-html-30">html</a></code> element, append an <code>embed</code> to the <code><a data-link-type="element" href="sections.html#elementdef-body" id="ref-for-elementdef-body-61">body</a></code> element, and set the <code>src</code> attribute of the <code><a data-link-type="element" href="semantics-embedded-content.html#elementdef-embed" id="ref-for-elementdef-embed-41">embed</a></code> element to the address of the resource.</p>
     <p class="note" role="note"> The term <a data-link-type="dfn" href="browsers.html#plugin-document" id="ref-for-plugin-document-1">plugin document</a> is used by <cite>Content Security Policy</cite> as part of the mechanism that ensures <code>iframe</code>s
  can’t be used to evade <code>plugin-types</code> directives. <a data-link-type="biblio" href="references.html#biblio-csp3">[CSP3]</a> </p>
     <p>Then, the user agent must act as if it had <a data-link-type="dfn" href="syntax.html#stopped" id="ref-for-stopped-7">stopped
  parsing</a>.</p>
     <p>After creating the <code>Document</code> object, but potentially before the page has finished
  fully loading, the user agent must <a data-link-type="dfn" href="browsers.html#updating-the-session-history-with-the-new-page" id="ref-for-updating-the-session-history-with-the-new-page-6">update the session history with the new page</a>.</p>
     <p>User agents may add content to the <code><a data-link-type="element" href="document-metadata.html#elementdef-head" id="ref-for-elementdef-head-47">head</a></code> element of the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>, or
  attributes to the <code><a data-link-type="element" href="semantics-embedded-content.html#elementdef-embed" id="ref-for-elementdef-embed-42">embed</a></code> element, e.g., to link to a style sheet,
  to give the document a <a data-link-type="element" href="document-metadata.html#elementdef-title" id="ref-for-elementdef-title-29"><code>title</code></a>, etc.</p>
     <p class="note" role="note"> If the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <a data-link-type="dfn" href="browsers.html#active-sandboxing-flag-set" id="ref-for-active-sandboxing-flag-set-20">active sandboxing
  flag set</a> has its <a data-link-type="dfn" href="browsers.html#sandboxed-plugins-browsing-context-flag" id="ref-for-sandboxed-plugins-browsing-context-flag-4">sandboxed plugins browsing context flag</a> set, the synthesized <code><a data-link-type="element" href="semantics-embedded-content.html#elementdef-embed" id="ref-for-elementdef-embed-43">embed</a></code> element will fail to render the content if
  the relevant <a data-link-type="dfn" href="infrastructure.html#plugin" id="ref-for-plugin-63">plugin</a> cannot be <a data-link-type="dfn" href="infrastructure.html#secured" id="ref-for-secured-7">secured</a>. </p>
     <h4 class="heading settled" data-level="6.7.8" id="page-load-processing-model-for-inline-content-that-doesnt-have-a-dom"><span class="secno">6.7.8. </span><span class="content"><dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="display the inline content" data-noexport="" id="display-the-inline-content">Page load processing model for inline content that doesn’t have a DOM</dfn></span><a class="self-link" href="browsers.html#page-load-processing-model-for-inline-content-that-doesnt-have-a-dom"></a></h4>
     <p>When the user agent is to display a user agent page inline in a <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-264">browsing context</a>,
  the user agent should create a <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object, mark it as being an <a data-link-type="dfn" href="infrastructure.html#html-document" id="ref-for-html-document-31">HTML document</a>, set its <a data-link-type="dfn" href="https://www.w3.org/TR/dom/#concept-document-content-type">content type</a> to "<a href="iana.html#text-html"><code>text/html</code></a>",
  initialize the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object, and then either associate that <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> with a custom rendering that is not rendered using the normal <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> rendering rules, or mutate that <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> until it represents
  the content the user agent wants to render.</p>
     <p>Once the page has been set up, the user agent must act as if it had <a data-link-type="dfn" href="syntax.html#stopped" id="ref-for-stopped-8">stopped parsing</a>.</p>
     <p>After creating the <code>Document</code> object, but potentially before the page has been
  completely set up, the user agent must <a data-link-type="dfn" href="browsers.html#updating-the-session-history-with-the-new-page" id="ref-for-updating-the-session-history-with-the-new-page-7">update the session history with the new
  page</a>.</p>
     <h4 class="heading settled" data-level="6.7.9" id="navigating-to-a-fragment-identifier"><span class="secno">6.7.9. </span><span class="content">Navigating to a <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="fragment identifier|fragment identifiers" data-noexport="" id="fragment-identifier">fragment identifier</dfn></span><a class="self-link" href="browsers.html#navigating-to-a-fragment-identifier"></a></h4>
     <p>When a user agent is supposed to navigate to a fragment identifier, then the user agent must
  run the following steps:</p>
     <ol>
      <li>
       <p>Remove all the entries in the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-265">browsing context</a>’s <a data-link-type="dfn" href="browsers.html#session-history" id="ref-for-session-history-24">session history</a> after the <a data-link-type="dfn" href="browsers.html#current-entry" id="ref-for-current-entry-23">current entry</a>. If the <a data-link-type="dfn" href="browsers.html#current-entry" id="ref-for-current-entry-24">current entry</a> is the last entry in the
    session history, then no entries are removed.</p>
       <p class="note" role="note"> This <a data-link-type="dfn" href="browsers.html#doesnt-necessarily-have-to-affect" id="ref-for-doesnt-necessarily-have-to-affect-3">doesn’t necessarily have to affect</a> the user
    agent’s user interface. </p>
      </li><li>Remove any <a data-link-type="dfn" href="webappapis.html#tasks" id="ref-for-tasks-83">tasks</a> queued by the <a data-link-type="dfn" href="webappapis.html#history-traversal-task-source" id="ref-for-history-traversal-task-source-3">history traversal
    task source</a> that are associated with any <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> objects in the <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-67">top-level browsing context</a>’s <a data-link-type="dfn" href="browsers.html#document-family" id="ref-for-document-family-5">document family</a>.
      </li><li>Append a new entry at the end of the <code>History</code> object representing the new
    resource and its <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object, related state, and current history scroll restoration preference. Its <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a> must be set to the address to which the user
   agent was <a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-81">navigating</a>. The title must be left unset.
      </li><li><a data-link-type="dfn" href="browsers.html#traverse-the-history" id="ref-for-traverse-the-history-7">Traverse the history</a> to the new entry, with the <i>non-blocking events</i> flag
    set. This will <a data-link-type="dfn" href="browsers.html#scroll-to-the-fragment-identifier" id="ref-for-scroll-to-the-fragment-identifier-2">scroll to the fragment
    identifier</a> given in what is now <a data-link-type="dfn" href="dom.html#the-document-address" id="ref-for-the-document-address-23">the document’s address</a>.
     </li></ol>
     <p class="note" role="note"> If the scrolling fails because the relevant <a data-link-type="dfn" href="https://www.w3.org/TR/dom/#concept-id">ID</a> has
  not yet been parsed, then the original <a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-82">navigation</a> algorithm will
  take care of the scrolling instead, as the last few steps of its <a data-link-type="dfn" href="browsers.html#updating-the-session-history-with-the-new-page" id="ref-for-updating-the-session-history-with-the-new-page-8">update the session history
  with the new page</a> algorithm. </p>
     <hr>
     <p>When the user agent is required to <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="scroll-to-the-fragment-identifier">scroll to the fragment identifier</dfn> and <a data-link-type="dfn" href="browsers.html#an-indicated-part-of-the-document" id="ref-for-an-indicated-part-of-the-document-2">the
  indicated part of the document</a>, if any, is <a data-link-type="dfn" href="rendering.html#being-rendered" id="ref-for-being-rendered-23">being rendered</a>, the user agent must
  either change the scrolling position of the document using the following algorithm, or perform
  some other action such that <a data-link-type="dfn" href="browsers.html#an-indicated-part-of-the-document" id="ref-for-an-indicated-part-of-the-document-3">the indicated part of the document</a> is brought to the
  user’s attention. If there is no indicated part, or if the indicated part is not <a data-link-type="dfn" href="rendering.html#being-rendered" id="ref-for-being-rendered-24">being
  rendered</a>, then the user agent must do nothing. The aforementioned algorithm is as
  follows:</p>
     <ol>
      <li>Let <var>target</var> be <a data-link-type="dfn" href="browsers.html#an-indicated-part-of-the-document" id="ref-for-an-indicated-part-of-the-document-4">the indicated part of the
    document</a>, as defined below.
      </li><li>If <var>target</var> is the top of the document, then <a data-link-type="dfn" href="https://www.w3.org/TR/cssom-view/#scroll-to-the-beginning-of-the-document">scroll to the beginning of the document</a> for the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>, and abort these steps. <a data-link-type="biblio" href="references.html#biblio-cssom-view">[CSSOM-VIEW]</a>
      </li><li>Use the <a data-link-type="dfn" href="https://www.w3.org/TR/cssom-view/#scroll-an-element-into-view">scroll an element into view</a> algorithm to scroll <var>target</var> into view, with the <var>align to top flag</var> set. <a data-link-type="biblio" href="references.html#biblio-cssom-view">[CSSOM-VIEW]</a>
      </li><li>Run the <a data-link-type="dfn" href="editing.html#focusing-steps" id="ref-for-focusing-steps-15">focusing steps</a> for that element, with the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <a data-link-type="dfn" href="infrastructure.html#viewport" id="ref-for-viewport-38">viewport</a> as the <i>fallback target</i>.
      </li><li>Move the <a data-link-type="dfn" href="editing.html#sequential-focus-navigation-starting-point" id="ref-for-sequential-focus-navigation-starting-point-5">sequential focus navigation starting point</a> to <var>target</var>. 
     </li></ol>
     <p><dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="an indicated part of the document|the indicated part of the document|indicated part of the document" data-noexport="" id="an-indicated-part-of-the-document">The indicated part of the document</dfn> is the one that the fragment identifier, if any,
  identifies. The semantics of the fragment identifier in terms of mapping it to a specific DOM Node
  is defined by the specification that defines the <a data-link-type="dfn" href="infrastructure.html#mime-type" id="ref-for-mime-type-36">MIME type</a> used by the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> (for example, the processing of fragment identifiers for <a data-link-type="dfn" href="infrastructure.html#xml-mime-type" id="ref-for-xml-mime-type-8">XML MIME types</a> is the responsibility of RFC7303). <a data-link-type="biblio" href="references.html#biblio-rfc7303">[RFC7303]</a></p>
     <p>For HTML documents (and <a data-link-type="dfn" href="infrastructure.html#html-mime-type" id="ref-for-html-mime-type-3">HTML MIME types</a>), the following
  processing model must be followed to determine what <a data-link-type="dfn" href="browsers.html#an-indicated-part-of-the-document" id="ref-for-an-indicated-part-of-the-document-5">the indicated part of the document</a> is.</p>
     <ol>
      <li>Apply the <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-parser">URL parser</a> algorithm to the <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a>, and let <var>fragid</var> be the <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-fragment">fragment</a> component of the <a data-link-type="dfn" href="infrastructure.html#resulting-url-record" id="ref-for-resulting-url-record-12">resulting URL record</a>.
      </li><li>If <var>fragid</var> is the empty string, then <a data-link-type="dfn" href="browsers.html#an-indicated-part-of-the-document" id="ref-for-an-indicated-part-of-the-document-6">the indicated part of the
    document</a> is the top of the document; stop the algorithm here.
      </li><li>Let <var>fragid bytes</var> be the result of percent decoding <var>fragid</var>.
      </li><li>Let <var>decoded fragid</var> be the result of running <a data-link-type="dfn" href="infrastructure.html#utf-8-decode-without-bom-or-fail" id="ref-for-utf-8-decode-without-bom-or-fail-1">UTF-8 decode without BOM or fail</a> on <var>fragid bytes</var>. If <var>decoded fragid</var> is failure, jump to the step labeled no <var>decoded fragid</var>.
      </li><li>If there is an element in the DOM that has an <a data-link-type="dfn" href="https://www.w3.org/TR/dom/#concept-id">ID</a> exactly
    equal to <var>decoded fragid</var>, then the first such element in <a data-link-type="dfn" href="infrastructure.html#tree-order" id="ref-for-tree-order-76">tree order</a> is <a data-link-type="dfn" href="browsers.html#an-indicated-part-of-the-document" id="ref-for-an-indicated-part-of-the-document-7">the indicated part of the document</a>; stop the algorithm here.
      </li><li><i>No decoded fragid</i>: If there is an <code><a data-link-type="element" href="textlevel-semantics.html#elementdef-a" id="ref-for-elementdef-a-97">a</a></code> element in the DOM that has a <code>name</code> attribute whose value is exactly equal to <var>fragid</var> (<em>not</em> <var>decoded fragid</var>), then the first such
    element in <a data-link-type="dfn" href="infrastructure.html#tree-order" id="ref-for-tree-order-77">tree order</a> is <a data-link-type="dfn" href="browsers.html#an-indicated-part-of-the-document" id="ref-for-an-indicated-part-of-the-document-8">the indicated part of the document</a>; stop the algorithm
    here.
      </li><li>If <var>fragid</var> is an <a data-link-type="dfn" href="infrastructure.html#ascii-case-insensitive" id="ref-for-ascii-case-insensitive-53">ASCII case-insensitive</a> match for the
    string <code>top</code>, then <a data-link-type="dfn" href="browsers.html#an-indicated-part-of-the-document" id="ref-for-an-indicated-part-of-the-document-9">the indicated part of the document</a> is the top
    of the document; stop the algorithm here.
      </li><li>Otherwise, there is no <a data-link-type="dfn" href="browsers.html#an-indicated-part-of-the-document" id="ref-for-an-indicated-part-of-the-document-10">indicated part of the document</a>.
     </li></ol>
     <p>For the purposes of the interaction of HTML with Selectors' <dfn class="css" data-dfn-type="selector" data-export="" id="selectordef-target"><code>:target</code><a class="self-link" href="browsers.html#selectordef-target"></a></dfn> pseudo-class, the <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="target-element"><i>target element</i></dfn> is <a data-link-type="dfn" href="browsers.html#an-indicated-part-of-the-document" id="ref-for-an-indicated-part-of-the-document-11">the indicated part of the document</a>, if that is an element; otherwise there is no <i>target element</i>. <a data-link-type="biblio" href="references.html#biblio-css3-selectors">[CSS3-SELECTORS]</a></p>
     <p>The <a data-link-type="dfn" href="webappapis.html#task-source" id="ref-for-task-source-22">task source</a> for the task mentioned in this section must be the <a data-link-type="dfn" href="webappapis.html#dom-manipulation-task-source" id="ref-for-dom-manipulation-task-source-14">DOM
  manipulation task source</a>.</p>
    </div>
    <h4 class="heading settled" data-level="6.7.10" id="history-traversal"><span class="secno">6.7.10. </span><span class="content">History traversal</span><a class="self-link" href="browsers.html#history-traversal"></a></h4>
    <div class="impl">
     <p>When a user agent is required to <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="traverse the history|history traversal|session history traversal|traversing the history" data-noexport="" id="traverse-the-history">traverse the history</dfn> to a <var>specified
  entry</var>, optionally with <a data-link-type="dfn" href="browsers.html#replacement-must-be-enabled" id="ref-for-replacement-must-be-enabled-21">replacement enabled</a>, and optionally with the <i>non-blocking events</i> flag set, the user agent must act as follows.</p>
     <p class="note" role="note"> This algorithm is not just invoked when <a data-link-type="dfn" href="browsers.html#explicitly-going-back-or-forwards-in-the-session-history" id="ref-for-explicitly-going-back-or-forwards-in-the-session-history-6">explicitly going back or forwards in the session history</a> — it is also invoked
  in other situations, for example when <a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-83">navigating a browsing context</a>,
  as part of <a data-link-type="dfn" href="browsers.html#updating-the-session-history-with-the-new-page" id="ref-for-updating-the-session-history-with-the-new-page-9">updating the session history
  with the new page</a>. </p>
     <ol>
      <li>
       <p>If there is no longer a <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object for the entry in question, <a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-84">navigate</a> the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-266">browsing
    context</a> to the resource for that entry to perform an <a data-link-type="dfn" href="browsers.html#entry-update" id="ref-for-entry-update-1">entry update</a> of that
    entry, and abort these steps. The "<a data-link-type="dfn" href="browsers.html#navigated" id="ref-for-navigated-85">navigate</a>" algorithm reinvokes this "traverse"
    algorithm to complete the traversal, at which point there <em>is</em> a <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object and so this step gets skipped. The navigation must be done using the same <a data-link-type="dfn" href="browsers.html#source-browsing-context" id="ref-for-source-browsing-context-20">source
    browsing context</a> as was used the first time this entry was created. (This can never
    happen with <a data-link-type="dfn" href="browsers.html#replacement-must-be-enabled" id="ref-for-replacement-must-be-enabled-22">replacement enabled</a>.)</p>
       <p class="note" role="note"> If the resource was obtained using a non-idempotent action, for example a POST <a data-link-type="dfn" href="sec-forms.html#form-submission" id="ref-for-form-submission-18">form submission</a>, or if the resource is no longer available, for example because the computer is
    now offline and the page wasn’t cached, navigating to it again might not be possible. In this
    case, the navigation will result in a different page than previously; for example, it might be
    an error message explaining the problem or offering to resubmit the form. </p>
      </li><li>If the <a data-link-type="dfn" href="browsers.html#current-entry" id="ref-for-current-entry-25">current entry</a>’s title was not set by the <code>pushState()</code> or <code>replaceState()</code> methods, then set its title to the value
    returned by the <code>document.title</code> IDL attribute.
      </li><li>If appropriate, update the <a data-link-type="dfn" href="browsers.html#current-entry" id="ref-for-current-entry-26">current entry</a> in the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-267">browsing
    context</a>’s <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object’s <code>History</code> object to reflect any state
    that the user agent wishes to persist. The entry is then said to be <a data-link-type="dfn" href="browsers.html#an-entry-with-persisted-user-state" id="ref-for-an-entry-with-persisted-user-state-2">an entry with persisted
    user state</a>.
      </li><li>
       If the <var>specified entry</var> has a different <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object
    than the <a data-link-type="dfn" href="browsers.html#current-entry" id="ref-for-current-entry-27">current entry</a>, then run the following substeps: 
       <ol>
        <li>Remove any <a data-link-type="dfn" href="webappapis.html#tasks" id="ref-for-tasks-84">tasks</a> queued by the <a data-link-type="dfn" href="webappapis.html#history-traversal-task-source" id="ref-for-history-traversal-task-source-4">history traversal
      task source</a> that are associated with any <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> objects in the <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-68">top-level browsing context</a>’s <a data-link-type="dfn" href="browsers.html#document-family" id="ref-for-document-family-6">document family</a>.
        </li><li>
         <p>If the <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-77">origin</a> of the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> of the <var>specified entry</var> is not the same as
      the <a data-link-type="dfn" href="browsers.html#concept-cross-origin" id="ref-for-concept-cross-origin-78">origin</a> of the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> of the <a data-link-type="dfn" href="browsers.html#current-entry" id="ref-for-current-entry-28">current entry</a>, then run the
      following sub-sub-steps:</p>
         <ol>
          <li>The current <a data-link-type="dfn" href="browsers.html#browsing-context-name" id="ref-for-browsing-context-name-14">browsing context name</a> must be stored with all the entries in
        the history that are associated with <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> objects with the <a data-link-type="dfn" href="browsers.html#same-origin" id="ref-for-same-origin-24">same
        origin</a> as the <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-89">active document</a> <em>and</em> that are contiguous with the <a data-link-type="dfn" href="browsers.html#current-entry" id="ref-for-current-entry-29">current entry</a>.
          </li><li><dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="gets reset" data-noexport="" id="gets-reset"></dfn>If the browsing context is a <a data-link-type="dfn" href="browsers.html#top-level-browsing-context" id="ref-for-top-level-browsing-context-69">top-level browsing context</a>,
        but not an <a data-link-type="dfn" href="browsers.html#auxiliary-browsing-contexts" id="ref-for-auxiliary-browsing-contexts-11">auxiliary browsing context</a>, then the browsing context’s <a data-link-type="dfn" href="browsers.html#browsing-context-name" id="ref-for-browsing-context-name-15">browsing context name</a> must be unset.
         </li></ol>
        </li><li>Make the <var>specified entry</var>’s <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object the <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-90">active document</a> of the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-268">browsing
      context</a>.
        </li><li>
         <p>If the <var>specified entry</var> has a <a data-link-type="dfn" href="browsers.html#browsing-context-name" id="ref-for-browsing-context-name-16">browsing context name</a> stored
      with it, then run the following sub-sub-steps:</p>
         <ol>
          <li>Set the browsing context’s <a data-link-type="dfn" href="browsers.html#browsing-context-name" id="ref-for-browsing-context-name-17">browsing context name</a> to the name stored with
        the specified entry.
          </li><li>Clear any <a data-link-type="dfn" href="browsers.html#browsing-context-name" id="ref-for-browsing-context-name-18">browsing context names</a> stored
        with all entries in the history that are associated with <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> objects with
        the <a data-link-type="dfn" href="browsers.html#same-origin" id="ref-for-same-origin-25">same origin</a> as the new <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-91">active document</a> and that are contiguous
        with the specified entry.
         </li></ol>
        </li><li>If the <var>specified entry</var>’s <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> has any form controls whose <a data-link-type="dfn" href="sec-forms.html#autofill-field-name" id="ref-for-autofill-field-name-28">autofill field name</a> is "<code>off</code>", invoke the <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="values are reset" data-noexport="" id="values-are-reset"></dfn> <a data-link-type="dfn" href="sec-forms.html#reset-algorithm" id="ref-for-reset-algorithm-8">reset algorithm</a> of each of those elements.
        </li><li>
         <p>If the <a data-link-type="dfn" href="dom.html#current-document-readiness" id="ref-for-current-document-readiness-6">current document readiness</a> of the <var>specified entry</var>’s <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> is "<code>complete</code>", <a data-link-type="dfn" href="webappapis.html#queuing" id="ref-for-queuing-124">queue a task</a> to run
      the following sub-sub-steps:</p>
         <ol>
          <li>If the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <a data-link-type="dfn" href="browsers.html#page-showing" id="ref-for-page-showing-1">page showing</a> flag is true, then abort this
        task (i.e., don’t fire the event below).
          </li><li>Set the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <a data-link-type="dfn" href="browsers.html#page-showing" id="ref-for-page-showing-2">page showing</a> flag to true.
          </li><li>
           <p>Run any <dfn data-dfn-type="dfn" data-noexport="" id="session-history-document-visibility-change-steps">session history document visibility change steps<a class="self-link" href="browsers.html#session-history-document-visibility-change-steps"></a></dfn> for <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> that
        are defined by <a data-link-type="dfn" href="infrastructure.html#applicable-specification" id="ref-for-applicable-specification-5">other applicable specifications</a>.</p>
           <p class="note" role="note"> This is specifically intended for use by the Page Visibility specification. <a data-link-type="biblio" href="references.html#biblio-page-visibility">[PAGE-VISIBILITY]</a> </p>
          </li><li><a data-link-type="dfn" href="infrastructure.html#fire" id="ref-for-fire-145">Fire</a> a <a data-link-type="dfn" href="infrastructure.html#trusted" id="ref-for-trusted-19">trusted</a> event with the name <code>pageshow</code> at the <code>Window</code> object of that <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>, with <i>target override</i> set to the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object,
        using the <code>PageTransitionEvent</code> interface, with the <code>persisted</code> attribute initialized to true.
        This event must not bubble, must not be cancelable, and has no default action.
         </li></ol>
       </li></ol>
      </li><li>Set <a data-link-type="dfn" href="dom.html#the-document-address" id="ref-for-the-document-address-24">the document’s address</a> to the URL of the <var>specified
    entry</var>.
      </li><li>If the <var>specified entry</var> has a URL whose fragment identifier differs
    from that of the <a data-link-type="dfn" href="browsers.html#current-entry" id="ref-for-current-entry-30">current entry</a>’s when compared in a <a data-link-type="dfn" href="infrastructure.html#case-sensitive" id="ref-for-case-sensitive-13">case-sensitive</a> manner, and the two share the same <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object, then let <var>hash
    changed</var> be true, and let <var>old URL</var> be the URL of the <a data-link-type="dfn" href="browsers.html#current-entry" id="ref-for-current-entry-31">current
    entry</a> and <var>new URL</var> be the URL of the <var>specified
    entry</var>. Otherwise, let <var>hash changed</var> be false.
      </li><li>If the traversal was initiated with <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="replacement must be enabled|replacement enabled" data-noexport="" id="replacement-must-be-enabled">replacement enabled</dfn>, remove the entry
    immediately before the <var>specified entry</var> in the session history.
      </li><li>If the <var>specified entry</var> is not <a data-link-type="dfn" href="browsers.html#an-entry-with-persisted-user-state" id="ref-for-an-entry-with-persisted-user-state-3">an entry with persisted user
    state</a>, but its URL has a fragment identifier, <a data-link-type="dfn" href="browsers.html#scroll-to-the-fragment-identifier" id="ref-for-scroll-to-the-fragment-identifier-3">scroll to the fragment
    identifier</a>.
      </li><li>If the entry is <a data-link-type="dfn" href="browsers.html#an-entry-with-persisted-user-state" id="ref-for-an-entry-with-persisted-user-state-4">an entry with persisted user state</a>, the user agent may <a data-link-type="dfn" href="browsers.html#restore-persisted-user-state" id="ref-for-restore-persisted-user-state-1">restore persisted user state</a> and update aspects of the document and its rendering.
      </li><li>Let <var>targetRealm</var> be the <a data-link-type="dfn" href="https://tc39.github.io/ecma262/#current-realm">current Realm Record</a>.
      </li><li>If the entry is a <a data-link-type="dfn" href="browsers.html#state-object" id="ref-for-state-object-10">state object</a> entry, let <var>state</var> be <a data-link-type="dfn" href="infrastructure.html#structuredclone" id="ref-for-structuredclone-14">StructuredClone</a>(that state object, <var>targetRealm</var>) of that state object. Otherwise, let <var>state</var> be
    null.
      </li><li>Set <code>history.state</code> to <var>state</var>.
      </li><li>Let <var>state changed</var> be true if the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> of the <var>specified entry</var> has a <a data-link-type="dfn" href="browsers.html#latest-entry" id="ref-for-latest-entry-3">latest entry</a>, and that entry is not the <var>specified entry</var>; otherwise let it be false. 
      </li><li>Let the <a data-link-type="dfn" href="browsers.html#latest-entry" id="ref-for-latest-entry-4">latest entry</a> of the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> of the <var>specified entry</var> be the <var>specified entry</var>.
      </li><li>
       <p>If the <i>non-blocking events</i> flag is not set, then run the following steps <a data-link-type="dfn" href="infrastructure.html#immediately" id="ref-for-immediately-13">immediately</a>. Otherwise, the <i>non-blocking events</i> flag is set; <a data-link-type="dfn" href="webappapis.html#queuing" id="ref-for-queuing-125">queue a task</a> to run the following substeps instead.</p>
       <ol>
        <li>If <var>state changed</var> is true, <a data-link-type="dfn" href="infrastructure.html#fire" id="ref-for-fire-146">fire</a> a <a data-link-type="dfn" href="infrastructure.html#trusted" id="ref-for-trusted-20">trusted</a> event with the name <code>popstate</code> at the <code>Window</code> object of the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>, using the <code>PopStateEvent</code> interface, with the <code>state</code> attribute initialized to the value of <var>state</var>. This event must bubble but not be cancelable and has no default
      action.
        </li><li>If <var>hash changed</var> is true, then <a data-link-type="dfn" href="infrastructure.html#fire" id="ref-for-fire-147">fire</a> a <a data-link-type="dfn" href="infrastructure.html#trusted" id="ref-for-trusted-21">trusted</a> event with the name <code>hashchange</code> at the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-269">browsing
      context</a>’s <code>Window</code> object, using the <code>HashChangeEvent</code> interface,
      with the <code>oldURL</code> attribute initialized to <var>old URL</var> and the <code>newURL</code> attribute
      initialized to <var>new URL</var>. This event must bubble but not be cancelable and
      has no default action.
       </li></ol>
      </li><li>The <a data-link-type="dfn" href="browsers.html#current-entry" id="ref-for-current-entry-32">current entry</a> is now the <var>specified entry</var>.
     </li></ol>
     <p>The <a data-link-type="dfn" href="webappapis.html#task-source" id="ref-for-task-source-23">task source</a> for the tasks mentioned above is the <a data-link-type="dfn" href="webappapis.html#dom-manipulation-task-source" id="ref-for-dom-manipulation-task-source-15">DOM manipulation task
  source</a>.</p>
    </div>
    <h5 class="heading settled" data-level="6.7.10.1" id="persisted-user-state-restoration"><span class="secno">6.7.10.1. </span><span class="content">Persisted user state restoration</span><a class="self-link" href="browsers.html#persisted-user-state-restoration"></a></h5>
    <div class="impl">
     <p>When the user agent is to <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="restore-persisted-user-state">restore persisted user state</dfn> from a history entry, it must
  run the following steps immediately:</p>
     <ol>
      <li>If the entry has a <a data-link-type="dfn" href="browsers.html#scroll-restoration-mode" id="ref-for-scroll-restoration-mode-10">scroll restoration mode</a>, let <var>scrollRestoration</var> be that. Otherwise let <var>scrollRestoration</var> be "<code>auto</code>"
      </li><li>If <var>scrollRestoration</var> is "<code>manual</code>" the user agent should not restore
   the scroll position for the document, otherwise, it may do so.
      </li><li>Optionally, update other aspects of the document and its rendering, for instance values of
   form fields, that the user agent had previously recorded.
     </li></ol>
    </div>
    <p class="note" role="note">This can even include updating the <code>dir</code> attribute
  of <code><a data-link-type="element" href="sec-forms.html#elementdef-textarea" id="ref-for-elementdef-textarea-84">textarea</a></code> elements or <code><a data-link-type="element" href="sec-forms.html#elementdef-input" id="ref-for-elementdef-input-292">input</a></code> elements whose <code>type</code> attribute
  is in either the <a data-link-type="element-state" href="sec-forms.html#element-statedef-input-text" id="ref-for-element-statedef-input-text-56">Text</a> state or the <a data-link-type="element-state" href="sec-forms.html#element-statedef-input-search" id="ref-for-element-statedef-input-search-19">Search</a> state, if the persisted state includes the
  directionality of user input in such controls.</p>
    <h5 class="heading settled" data-level="6.7.10.2" id="the-popstateevent-interface"><span class="secno">6.7.10.2. </span><span class="content">The <code>PopStateEvent</code> interface</span><a class="self-link" href="browsers.html#the-popstateevent-interface"></a></h5>
<pre class="idl highlight def" data-highlight="webidl">[<dfn class="nv idl-code" data-dfn-for="PopStateEvent" data-dfn-type="constructor" data-export="" data-lt="PopStateEvent(type, eventInitDict)|PopStateEvent(type)" id="dom-popstateevent-popstateevent">Constructor<a class="self-link" href="browsers.html#dom-popstateevent-popstateevent"></a></dfn>(<span class="kt">DOMString</span> <dfn class="nv idl-code" data-dfn-for="PopStateEvent/PopStateEvent(type, eventInitDict)" data-dfn-type="argument" data-export="" id="dom-popstateevent-popstateevent-type-eventinitdict-type">type<a class="self-link" href="browsers.html#dom-popstateevent-popstateevent-type-eventinitdict-type"></a></dfn>, <span class="kt">optional</span> <a class="n" data-link-type="idl-name" href="browsers.html#dictdef-popstateeventinit-popstateeventinit" id="ref-for-dictdef-popstateeventinit-popstateeventinit-1">PopStateEventInit</a> <dfn class="nv idl-code" data-dfn-for="PopStateEvent/PopStateEvent(type, eventInitDict)" data-dfn-type="argument" data-export="" id="dom-popstateevent-popstateevent-type-eventinitdict-eventinitdict">eventInitDict<a class="self-link" href="browsers.html#dom-popstateevent-popstateevent-type-eventinitdict-eventinitdict"></a></dfn>), <a class="nv idl-code" data-link-type="extended-attribute">Exposed</a>=(<span class="n">Window</span>,<span class="n">Worker</span>)]
<span class="kt">interface</span> <dfn class="nv dfn-paneled idl-code" data-dfn-for="PopStateEvent" data-dfn-type="interface" data-export="" id="popstateevent-popstateevent">PopStateEvent</dfn> : <a class="n" data-link-type="idl-name" href="https://www.w3.org/TR/dom/#event">Event</a> {
  <span class="kt">readonly</span> <span class="kt">attribute</span> <span class="kt">any</span> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="any" href="browsers.html#dom-popstateevent-state" id="ref-for-dom-popstateevent-state-1">state</a>;
};
</pre>
<pre class="idl highlight def" data-highlight="webidl"><span class="kt">dictionary</span> <dfn class="nv dfn-paneled idl-code" data-dfn-for="PopStateEventInit" data-dfn-type="dictionary" data-export="" id="dictdef-popstateeventinit-popstateeventinit">PopStateEventInit</dfn> : <a class="n" data-link-type="idl-name" href="https://dom.spec.whatwg.org/#dictdef-eventinit">EventInit</a> {
  <span class="kt">any</span> <dfn class="nv idl-code" data-dfn-for="PopStateEventInit" data-dfn-type="dict-member" data-export="" data-type="any " id="dom-popstateeventinit-state">state<a class="self-link" href="browsers.html#dom-popstateeventinit-state"></a></dfn>;
};
</pre>
    <dl class="domintro">
     <dt><var>event</var> . <code>state</code>
     </dt><dd>
      <p>Returns a copy of the information that was provided to <code>pushState()</code> or <code>replaceState()</code>.</p>
    </dd></dl>
    <div class="impl">
     <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="PopStateEvent" data-dfn-type="attribute" data-export="" id="dom-popstateevent-state"><code>state</code></dfn> attribute must return the
  value it was initialized to. When the object is created, this attribute must be initialized to
  null. It represents the context information for the event, or null, if the state represented is
  the initial state of the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>.</p>
    </div>
    <h5 class="heading settled" data-level="6.7.10.3" id="the-hashchangeevent-interface"><span class="secno">6.7.10.3. </span><span class="content">The <code>HashChangeEvent</code> interface</span><a class="self-link" href="browsers.html#the-hashchangeevent-interface"></a></h5>
<pre class="idl highlight def" data-highlight="webidl">[<dfn class="nv idl-code" data-dfn-for="HashChangeEvent" data-dfn-type="constructor" data-export="" data-lt="HashChangeEvent(type, eventInitDict)|HashChangeEvent(type)" id="dom-hashchangeevent-hashchangeevent">Constructor<a class="self-link" href="browsers.html#dom-hashchangeevent-hashchangeevent"></a></dfn>(<span class="kt">DOMString</span> <dfn class="nv idl-code" data-dfn-for="HashChangeEvent/HashChangeEvent(type, eventInitDict)" data-dfn-type="argument" data-export="" id="dom-hashchangeevent-hashchangeevent-type-eventinitdict-type">type<a class="self-link" href="browsers.html#dom-hashchangeevent-hashchangeevent-type-eventinitdict-type"></a></dfn>, <span class="kt">optional</span> <a class="n" data-link-type="idl-name" href="browsers.html#dictdef-hashchangeeventinit-hashchangeeventinit" id="ref-for-dictdef-hashchangeeventinit-hashchangeeventinit-1">HashChangeEventInit</a> <dfn class="nv idl-code" data-dfn-for="HashChangeEvent/HashChangeEvent(type, eventInitDict)" data-dfn-type="argument" data-export="" id="dom-hashchangeevent-hashchangeevent-type-eventinitdict-eventinitdict">eventInitDict<a class="self-link" href="browsers.html#dom-hashchangeevent-hashchangeevent-type-eventinitdict-eventinitdict"></a></dfn>), <a class="nv idl-code" data-link-type="extended-attribute">Exposed</a>=(<span class="n">Window</span>,<span class="n">Worker</span>)]
<span class="kt">interface</span> <dfn class="nv dfn-paneled idl-code" data-dfn-for="HashChangeEvent" data-dfn-type="interface" data-export="" id="hashchangeevent-hashchangeevent">HashChangeEvent</dfn> : <a class="n" data-link-type="idl-name" href="https://www.w3.org/TR/dom/#event">Event</a> {
  <span class="kt">readonly</span> <span class="kt">attribute</span> <span class="kt">DOMString</span> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="DOMString" href="browsers.html#dom-hashchangeevent-oldurl" id="ref-for-dom-hashchangeevent-oldurl-1">oldURL</a>;
  <span class="kt">readonly</span> <span class="kt">attribute</span> <span class="kt">DOMString</span> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="DOMString" href="browsers.html#dom-hashchangeevent-newurl" id="ref-for-dom-hashchangeevent-newurl-1">newURL</a>;
};
</pre>
<pre class="idl highlight def" data-highlight="webidl"><span class="kt">dictionary</span> <dfn class="nv dfn-paneled idl-code" data-dfn-for="HashChangeEventInit" data-dfn-type="dictionary" data-export="" id="dictdef-hashchangeeventinit-hashchangeeventinit">HashChangeEventInit</dfn> : <a class="n" data-link-type="idl-name" href="https://dom.spec.whatwg.org/#dictdef-eventinit">EventInit</a> {
  <span class="kt">DOMString</span> <dfn class="nv idl-code" data-dfn-for="HashChangeEventInit" data-dfn-type="dict-member" data-export="" data-type="DOMString " id="dom-hashchangeeventinit-oldurl">oldURL<a class="self-link" href="browsers.html#dom-hashchangeeventinit-oldurl"></a></dfn>;
  <span class="kt">DOMString</span> <dfn class="nv idl-code" data-dfn-for="HashChangeEventInit" data-dfn-type="dict-member" data-export="" data-type="DOMString " id="dom-hashchangeeventinit-newurl">newURL<a class="self-link" href="browsers.html#dom-hashchangeeventinit-newurl"></a></dfn>;
};
</pre>
    <dl class="domintro">
     <dt><var>event</var> . <code>oldURL</code>
     </dt><dd>
      <p>Returns the <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a> of the <a data-link-type="dfn" href="browsers.html#session-history-entry" id="ref-for-session-history-entry-6">session history entry</a> that was previously
    current.</p>
     </dd><dt><var>event</var> . <code>newURL</code>
     </dt><dd>
      <p>Returns the <a data-link-type="dfn" href="https://url.spec.whatwg.org/#concept-url-url">URL</a> of the <a data-link-type="dfn" href="browsers.html#session-history-entry" id="ref-for-session-history-entry-7">session history entry</a> that is now
    current.</p>
    </dd></dl>
    <div class="impl">
     <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="HashChangeEvent" data-dfn-type="attribute" data-export="" id="dom-hashchangeevent-oldurl"><code>oldURL</code></dfn> attribute must return the
  value it was initialized to. When the object is created, this attribute must be initialized to
  null. It represents context information for the event, specifically the URL of the <a data-link-type="dfn" href="browsers.html#session-history-entry" id="ref-for-session-history-entry-8">session
  history entry</a> that was traversed from.</p>
     <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="HashChangeEvent" data-dfn-type="attribute" data-export="" id="dom-hashchangeevent-newurl"><code>newURL</code></dfn> attribute must return the
  value it was initialized to. When the object is created, this attribute must be initialized to
  null. It represents context information for the event, specifically the URL of the <a data-link-type="dfn" href="browsers.html#session-history-entry" id="ref-for-session-history-entry-9">session
  history entry</a> that was traversed to.</p>
    </div>
    <h5 class="heading settled" data-level="6.7.10.4" id="the-pagetransitionevent-interface"><span class="secno">6.7.10.4. </span><span class="content">The <code>PageTransitionEvent</code> interface</span><a class="self-link" href="browsers.html#the-pagetransitionevent-interface"></a></h5>
<pre class="idl highlight def" data-highlight="webidl">[<dfn class="nv idl-code" data-dfn-for="PageTransitionEvent" data-dfn-type="constructor" data-export="" data-lt="PageTransitionEvent(type, eventInitDict)|PageTransitionEvent(type)" id="dom-pagetransitionevent-pagetransitionevent">Constructor<a class="self-link" href="browsers.html#dom-pagetransitionevent-pagetransitionevent"></a></dfn>(<span class="kt">DOMString</span> <dfn class="nv idl-code" data-dfn-for="PageTransitionEvent/PageTransitionEvent(type, eventInitDict)" data-dfn-type="argument" data-export="" id="dom-pagetransitionevent-pagetransitionevent-type-eventinitdict-type">type<a class="self-link" href="browsers.html#dom-pagetransitionevent-pagetransitionevent-type-eventinitdict-type"></a></dfn>, <span class="kt">optional</span> <a class="n" data-link-type="idl-name" href="browsers.html#dictdef-pagetransitioneventinit-pagetransitioneventinit" id="ref-for-dictdef-pagetransitioneventinit-pagetransitioneventinit-1">PageTransitionEventInit</a> <dfn class="nv idl-code" data-dfn-for="PageTransitionEvent/PageTransitionEvent(type, eventInitDict)" data-dfn-type="argument" data-export="" id="dom-pagetransitionevent-pagetransitionevent-type-eventinitdict-eventinitdict">eventInitDict<a class="self-link" href="browsers.html#dom-pagetransitionevent-pagetransitionevent-type-eventinitdict-eventinitdict"></a></dfn>), <a class="nv idl-code" data-link-type="extended-attribute">Exposed</a>=(<span class="n">Window</span>,<span class="n">Worker</span>)]
<span class="kt">interface</span> <dfn class="nv dfn-paneled idl-code" data-dfn-for="PageTransitionEvent" data-dfn-type="interface" data-export="" id="pagetransitionevent-pagetransitionevent">PageTransitionEvent</dfn> : <a class="n" data-link-type="idl-name" href="https://www.w3.org/TR/dom/#event">Event</a> {
  <span class="kt">readonly</span> <span class="kt">attribute</span> <span class="kt">boolean</span> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="boolean" href="browsers.html#dom-pagetransitionevent-persisted" id="ref-for-dom-pagetransitionevent-persisted-1">persisted</a>;
};
</pre>
<pre class="idl highlight def" data-highlight="webidl"><span class="kt">dictionary</span> <dfn class="nv dfn-paneled idl-code" data-dfn-for="PageTransitionEventInit" data-dfn-type="dictionary" data-export="" id="dictdef-pagetransitioneventinit-pagetransitioneventinit">PageTransitionEventInit</dfn> : <a class="n" data-link-type="idl-name" href="https://dom.spec.whatwg.org/#dictdef-eventinit">EventInit</a> {
  <span class="kt">boolean</span> <dfn class="nv idl-code" data-dfn-for="PageTransitionEventInit" data-dfn-type="dict-member" data-export="" data-type="boolean " id="dom-pagetransitioneventinit-persisted">persisted<a class="self-link" href="browsers.html#dom-pagetransitioneventinit-persisted"></a></dfn>;
};
</pre>
    <dl class="domintro">
     <dt><var>event</var> . <code>persisted</code>
     </dt><dd>
      <p>For the <code>pageshow</code> event, returns false if the page is
    newly being loaded (and the <code>load</code> event will fire). Otherwise,
    returns true.</p>
      <p>For the <code>pagehide</code> event, returns false if the page is
    going away for the last time. Otherwise, returns true, meaning that (if nothing conspires to
    make the page unsalvageable) the page might be reused if the user navigates back to this
    page.</p>
      <p>Things that can cause the page to be unsalvageable include:</p>
      <ul class="brief">
       <li><code>document.open()</code> 
       </li><li>Listening for <code>beforeunload</code> events 
       </li><li>Listening for <code>unload</code> events 
       </li><li>Having <code>iframe</code>s that are not salvageable 
       </li><li>Active <code>WebSocket</code> objects 
       </li><li><a data-link-type="dfn" href="browsers.html#abort-the-document" id="ref-for-abort-the-document-6">Aborting a <code>Document</code></a> 
      </li></ul>
    </dd></dl>
    <div class="impl">
     <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="PageTransitionEvent" data-dfn-type="attribute" data-export="" id="dom-pagetransitionevent-persisted"><code>persisted</code></dfn> attribute must
  return the value it was initialized to. When the object is created, this attribute must be
  initialized to false. It represents the context information for the event.</p>
    </div>
    <h4 class="heading settled" data-level="6.7.11" id="unloading-documents"><span class="secno">6.7.11. </span><span class="content">Unloading documents</span><a class="self-link" href="browsers.html#unloading-documents"></a></h4>
    <div class="impl">
     <p>A <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> has a <dfn data-dfn-type="dfn" data-noexport="" id="salvageable"><i>salvageable</i><a class="self-link" href="browsers.html#salvageable"></a></dfn> state, which must initially be
  true, a <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="fired-unload">fired unload</dfn> flag, which must initially be false, and a <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="page-showing">page showing</dfn> flag, which must initially be false. The <a data-link-type="dfn" href="browsers.html#page-showing" id="ref-for-page-showing-3">page showing</a> flag is used to ensure that
  scripts receive <code>pageshow</code> and <code>pagehide</code> events in a consistent manner (e.g., that they never
  receive two <code>pagehide</code> events in a row without an intervening <code>pageshow</code>, or vice versa).</p>
     <p><a data-link-type="dfn" href="webappapis.html#event-loop" id="ref-for-event-loop-35">Event loops</a> have a <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="termination-nesting-level">termination nesting level</dfn> counter, which must initially be zero.</p>
     <p>When a user agent is to <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="prompt to unload|prompt to unload a document" data-noexport="" id="prompt-to-unload">prompt to unload a document</dfn>, it must run the following
  steps.</p>
     <ol>
      <li>Increase the <a data-link-type="dfn" href="webappapis.html#event-loop" id="ref-for-event-loop-36">event loop</a>’s <a data-link-type="dfn" href="browsers.html#termination-nesting-level" id="ref-for-termination-nesting-level-1">termination nesting level</a> by
    one.
      </li><li>Increase the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <a data-link-type="dfn" href="webappapis.html#ignore-opens-during-unload-counter" id="ref-for-ignore-opens-during-unload-counter-1">ignore-opens-during-unload counter</a> by
    one.
      </li><li>Let <var>event</var> be a new <a data-link-type="dfn" href="infrastructure.html#trusted" id="ref-for-trusted-22">trusted</a> <code>BeforeUnloadEvent</code> event object with the name <code>beforeunload</code>, which does not bubble but is cancelable.
      </li><li><i>Dispatch</i>: <a data-link-type="dfn" href="infrastructure.html#dispatch" id="ref-for-dispatch-7">Dispatch</a> <var>event</var> at the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <code>Window</code> object.
      </li><li>Decrease the <a data-link-type="dfn" href="webappapis.html#event-loop" id="ref-for-event-loop-37">event loop</a>’s <a data-link-type="dfn" href="browsers.html#termination-nesting-level" id="ref-for-termination-nesting-level-2">termination nesting level</a> by
    one.
      </li><li>If any event listeners were triggered by the earlier <i>dispatch</i> step, then set the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <i>salvageable</i> state to
    false.
      </li><li>
       <p>If the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <a data-link-type="dfn" href="browsers.html#active-sandboxing-flag-set" id="ref-for-active-sandboxing-flag-set-21">active sandboxing flag set</a> does not have its <a data-link-type="dfn" href="browsers.html#sandboxed-modals-flag" id="ref-for-sandboxed-modals-flag-2">sandboxed modals flag</a> set, and the <code class="idl"><a data-link-type="idl" href="browsers.html#dom-beforeunloadevent-returnvalue" id="ref-for-dom-beforeunloadevent-returnvalue-1">returnValue</a></code> attribute of the <var>event</var> object is not the empty string, or if the event was canceled, then the user
    agent should ask the user to confirm that they wish to unload the document.</p>
       <p>The prompt shown by the user agent may include the string of the <code class="idl"><a data-link-type="idl" href="browsers.html#dom-beforeunloadevent-returnvalue" id="ref-for-dom-beforeunloadevent-returnvalue-2">returnValue</a></code> attribute, or some leading subset thereof. (A user agent may
    want to truncate the string to 1024 characters for display, for instance.)</p>
       <p>The user agent must <a data-link-type="state" href="webappapis.html#statedef-useragent-pause" id="ref-for-statedef-useragent-pause-2">pause</a> while waiting for the user’s response.</p>
       <p>If the user did not confirm the page navigation, then the user agent <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="refused to allow the document to be unloaded|refused to allow this document to be unloaded" data-noexport="" id="refused-to-allow-the-document-to-be-unloaded">refused to allow the document to be unloaded</dfn>.</p>
      </li><li>If this algorithm was invoked by another instance of the "prompt to unload a document"
    algorithm (i.e., through the steps below that invoke this algorithm for all descendant browsing
    contexts), then jump to the step labeled <i>end</i>.
      </li><li>Let <var>descendants</var> be the <a data-link-type="dfn" href="browsers.html#list-of-the-descendant-browsing-contexts" id="ref-for-list-of-the-descendant-browsing-contexts-2">list of the descendant browsing
    contexts</a> of the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>.
      </li><li>
       <p>If <var>descendants</var> is not an empty list, then for each <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-270">browsing
    context</a> <var>b</var> in <var>descendants</var> run the following
    substeps:</p>
       <ol>
        <li><a data-link-type="dfn" href="browsers.html#prompt-to-unload" id="ref-for-prompt-to-unload-7">Prompt to unload</a> the <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-92">active
      document</a> of the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-271">browsing context</a> <var>b</var>. If the user <a data-link-type="dfn" href="browsers.html#refused-to-allow-the-document-to-be-unloaded" id="ref-for-refused-to-allow-the-document-to-be-unloaded-4">refused to allow the document to be unloaded</a>, then the user implicitly also <a data-link-type="dfn" href="browsers.html#refused-to-allow-the-document-to-be-unloaded" id="ref-for-refused-to-allow-the-document-to-be-unloaded-5">refused to allow <em>this</em> document to be unloaded</a>; jump to the step labeled <i>end</i>. 
        </li><li>If the <i>salvageable</i> state of the <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-93">active
      document</a> of the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-272">browsing context</a> <var>b</var> is false, then set
      the <i>salvageable</i> state of <em>this</em> document to
      false also.
       </li></ol>
      </li><li><i>End</i>: Decrease the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <a data-link-type="dfn" href="webappapis.html#ignore-opens-during-unload-counter" id="ref-for-ignore-opens-during-unload-counter-2">ignore-opens-during-unload
    counter</a> by one.
     </li></ol>
     <p>When a user agent is to <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="unloaded|unload|unload a document|being unloaded" data-noexport="" id="unloaded">unload a document</dfn>, it must run the following steps. These
  steps are passed an argument, <var>recycle</var>, which is either true or false,
  indicating whether the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object is going to be re-used. (This is set by the <code>document.open()</code> method.)</p>
     <ol>
      <li>Increase the <a data-link-type="dfn" href="webappapis.html#event-loop" id="ref-for-event-loop-38">event loop</a>’s <a data-link-type="dfn" href="browsers.html#termination-nesting-level" id="ref-for-termination-nesting-level-3">termination nesting level</a> by
    one.
      </li><li>Increase the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <a data-link-type="dfn" href="webappapis.html#ignore-opens-during-unload-counter" id="ref-for-ignore-opens-during-unload-counter-3">ignore-opens-during-unload counter</a> by
    one.
      </li><li>If the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <a data-link-type="dfn" href="browsers.html#page-showing" id="ref-for-page-showing-4">page showing</a> flag is false, then jump to the
    step labeled <i>unload event</i> below (i.e., skip firing the <code>pagehide</code> event and don’t rerun the <a data-link-type="dfn" href="browsers.html#unloading-document-visibility-change-steps" id="ref-for-unloading-document-visibility-change-steps-1">unloading document
    visibility change steps</a>).
      </li><li>Set the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <a data-link-type="dfn" href="browsers.html#page-showing" id="ref-for-page-showing-5">page showing</a> flag to false.
      </li><li><a data-link-type="dfn" href="infrastructure.html#fire" id="ref-for-fire-148">Fire</a> a <a data-link-type="dfn" href="infrastructure.html#trusted" id="ref-for-trusted-23">trusted</a> event with the name <code>pagehide</code> at the <code>Window</code> object of the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>, with <i>target override</i> set to the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object, using the <code>PageTransitionEvent</code> interface,
    with the <code>persisted</code> attribute initialized
    to true if the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object’s <i>salvageable</i> state is true, and false otherwise. This
    event must not bubble, must not be cancelable, and has no default action.
      </li><li>
       <p>Run any <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="unloading-document-visibility-change-steps">unloading document visibility change steps</dfn> for <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> that
    are defined by <a data-link-type="dfn" href="infrastructure.html#applicable-specification" id="ref-for-applicable-specification-6">other applicable specifications</a>.</p>
       <p class="note" role="note"> This is specifically intended for use by the Page Visibility specification. <a data-link-type="biblio" href="references.html#biblio-page-visibility">[PAGE-VISIBILITY]</a> </p>
      </li><li><i>Unload event</i>: If the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <a data-link-type="dfn" href="browsers.html#fired-unload" id="ref-for-fired-unload-1">fired unload</a> flag is
    false, <a data-link-type="dfn" href="infrastructure.html#fire" id="ref-for-fire-149">fire a simple event</a> named <code>unload</code> at the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <code>Window</code> object, with <i>target override</i> set to the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object.
      </li><li>Decrease the <a data-link-type="dfn" href="webappapis.html#event-loop" id="ref-for-event-loop-39">event loop</a>’s <a data-link-type="dfn" href="browsers.html#termination-nesting-level" id="ref-for-termination-nesting-level-4">termination nesting level</a> by
    one.
      </li><li>If any event listeners were triggered by the earlier <i>unload event</i> step, then set
    the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> object’s <i>salvageable</i> state
    to false and set the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <a data-link-type="dfn" href="browsers.html#fired-unload" id="ref-for-fired-unload-2">fired unload</a> flag to true.
      </li><li>Run any <a data-link-type="dfn" href="browsers.html#unloading-document-cleanup-steps" id="ref-for-unloading-document-cleanup-steps-2">unloading document cleanup steps</a> for <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> that are
    defined by this specification and <a data-link-type="dfn" href="infrastructure.html#applicable-specification" id="ref-for-applicable-specification-7">other applicable specifications</a>.
      </li><li>If this algorithm was invoked by another instance of the "unload a document" algorithm
    (i.e., by the steps below that invoke this algorithm for all descendant browsing contexts), then
    jump to the step labeled <i>end</i>.
      </li><li>Let <var>descendants</var> be the <a data-link-type="dfn" href="browsers.html#list-of-the-descendant-browsing-contexts" id="ref-for-list-of-the-descendant-browsing-contexts-3">list of the descendant browsing
    contexts</a> of the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>.
      </li><li>
       <p>If <var>descendants</var> is not an empty list, then for each <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-273">browsing
    context</a> <var>b</var> in <var>descendants</var> run the following
    substeps:</p>
       <ol>
        <li><a data-link-type="dfn" href="browsers.html#unloaded" id="ref-for-unloaded-12">Unload</a> the <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-94">active document</a> of the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-274">browsing context</a> <var>b</var> with the <var>recycle</var> parameter set to false.
        </li><li>If the <i>salvageable</i> state of the <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-95">active
      document</a> of the <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-275">browsing context</a> <var>b</var> is false, then set
      the <i>salvageable</i> state of <em>this</em> document to
      false also.
       </li></ol>
      </li><li>If both the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <i>salvageable</i> state and <var>recycle</var> are
    false, then the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <a data-link-type="dfn" href="browsers.html#browsing-context" id="ref-for-browsing-context-276">browsing context</a> must <a data-link-type="dfn" href="browsers.html#discard-the-document" id="ref-for-discard-the-document-1">discard the <code>Document</code></a>.
      </li><li><i>End</i>: Decrease the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <a data-link-type="dfn" href="webappapis.html#ignore-opens-during-unload-counter" id="ref-for-ignore-opens-during-unload-counter-4">ignore-opens-during-unload
    counter</a> by one.
     </li></ol>
     <p>This specification defines the following <dfn class="dfn-paneled" data-dfn-type="dfn" data-noexport="" id="unloading-document-cleanup-steps">unloading document cleanup steps</dfn>. Other
  specifications can define more.</p>
     <ol>
      <li>
       <p>Make disappear any <code>WebSocket</code> objects that were created by the <code>WebSocket()</code> constructor from the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <code>Window</code> object.</p>
       <p>If this affected any <code>WebSocket</code> objects, then set <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <i>salvageable</i> state to false.</p>
      </li><li>If the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <i>salvageable</i> state is false, forcibly close any <code>EventSource</code> objects that whose constructor was invoked from the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <code>Window</code> object.
      </li><li>If the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <i>salvageable</i> state is false, empty the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <code>Window</code>’s <a data-link-type="dfn" href="webappapis.html#list-of-active-timers" id="ref-for-list-of-active-timers-1">list of active
    timers</a>.
     </li></ol>
    </div>
    <h5 class="heading settled" data-level="6.7.11.1" id="the-beforeunloadevent-interface"><span class="secno">6.7.11.1. </span><span class="content">The <code>BeforeUnloadEvent</code> interface</span><a class="self-link" href="browsers.html#the-beforeunloadevent-interface"></a></h5>
<pre class="idl highlight def" data-highlight="webidl"><span class="kt">interface</span> <dfn class="nv dfn-paneled idl-code" data-dfn-for="BeforeUnloadEvent" data-dfn-type="interface" data-export="" id="beforeunloadevent-beforeunloadevent">BeforeUnloadEvent</dfn> : <a class="n" data-link-type="idl-name" href="https://www.w3.org/TR/dom/#event">Event</a> {
  <span class="kt">attribute</span> <span class="kt">DOMString</span> <a class="nv idl-code" data-link-type="attribute" data-type="DOMString" href="browsers.html#dom-beforeunloadevent-returnvalue" id="ref-for-dom-beforeunloadevent-returnvalue-3">returnValue</a>;
};
</pre>
    <dl class="domintro">
     <dt><var>event</var> . <code class="idl"><a data-link-type="idl" href="browsers.html#dom-beforeunloadevent-returnvalue" id="ref-for-dom-beforeunloadevent-returnvalue-4">returnValue</a></code> [ = <var>value</var> ]
     </dt><dd>
      <p>Returns the current return value of the event (the message to show the user).</p>
      <p>Can be set, to update the message.</p>
    </dd></dl>
    <p class="note" role="note"> There are no <code>BeforeUnloadEvent</code>-specific initialization methods. </p>
    <div class="impl">
     <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="BeforeUnloadEvent" data-dfn-type="attribute" data-export="" id="dom-beforeunloadevent-returnvalue"><code>returnValue</code></dfn> attribute
  represents the message to show the user. When the event is created, the attribute must be set to
  the empty string. On getting, it must return the last value it was set to. On setting, the
  attribute must be set to the new value.</p>
    </div>
    <div class="impl">
     <h4 class="heading settled" data-level="6.7.12" id="aborting-a-document-load"><span class="secno">6.7.12. </span><span class="content">Aborting a document load</span><a class="self-link" href="browsers.html#aborting-a-document-load"></a></h4>
     <p>If a <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> is <dfn class="dfn-paneled" data-dfn-type="dfn" data-lt="abort the document|aborted|aborting a document|abort a document" data-noexport="" id="abort-the-document">aborted</dfn>, the user agent must
  run the following steps:</p>
     <ol>
      <li><a data-link-type="dfn" href="browsers.html#abort-the-document" id="ref-for-abort-the-document-7">Abort</a> the <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-96">active
    documents</a> of every <a data-link-type="dfn" href="browsers.html#child-browsing-context" id="ref-for-child-browsing-context-25">child browsing context</a>. If this results in any of those <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> objects having their <i>salvageable</i> state set to false, then set this <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <i>salvageable</i> state to false
    also.
      </li><li>Cancel any instances of the <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-fetch">fetch</a> algorithm in the
    context of this <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>, discarding any <a data-link-type="dfn" href="webappapis.html#tasks" id="ref-for-tasks-85">tasks</a> <a data-link-type="dfn" href="webappapis.html#queue-a-microtask" id="ref-for-queue-a-microtask-31">queued</a> for them, and discarding any further data received from
    the network for them. If this resulted in any instances of the <a data-link-type="dfn" href="https://fetch.spec.whatwg.org/#concept-fetch">fetch</a> algorithm being canceled or any <a data-link-type="dfn" href="webappapis.html#queue-a-microtask" id="ref-for-queue-a-microtask-32">queued</a> <a data-link-type="dfn" href="webappapis.html#tasks" id="ref-for-tasks-86">tasks</a> or any network data getting
    discarded, then set the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <i>salvageable</i> state to false.
      </li><li>If the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> has an <a data-link-type="dfn" href="dom.html#active-parser" id="ref-for-active-parser-1">active parser</a>, then <a data-link-type="dfn" href="syntax.html#abort-the-parser" id="ref-for-abort-the-parser-1">abort that parser</a> and set the <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <i>salvageable</i> state to false.
     </li></ol>
     <p>User agents may allow users to explicitly invoke the <a data-link-type="dfn" href="browsers.html#abort-the-document" id="ref-for-abort-the-document-8">abort a
  document</a> algorithm for a <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>. If the user does so, then, if that <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code> is an <a data-link-type="dfn" href="browsers.html#active-document" id="ref-for-active-document-97">active document</a>, the user agent should <a data-link-type="dfn" href="webappapis.html#queuing" id="ref-for-queuing-126">queue a
  task</a> to <a data-link-type="dfn" href="infrastructure.html#fire" id="ref-for-fire-150">fire a simple event</a> named <code>abort</code> at
  that <code class="idl"><a data-link-type="idl" href="https://www.w3.org/TR/dom/#document">Document</a></code>'s <code>Window</code> object before invoking the <a data-link-type="dfn" href="browsers.html#abort-the-document" id="ref-for-abort-the-document-9">abort</a> algorithm.</p>
    </div>
    <h4 class="heading settled" data-level="6.7.13" id="browser-state"><span class="secno">6.7.13. </span><span class="content">Browser state</span><a class="self-link" href="browsers.html#browser-state"></a></h4>
<pre class="idl highlight def" data-highlight="webidl">[<a class="nv idl-code" data-link-type="extended-attribute">NoInterfaceObject</a>, <a class="nv idl-code" data-link-type="extended-attribute">Exposed</a>=(<span class="n">Window</span>, <span class="n">Worker</span>)]
<span class="kt">interface</span> <dfn class="nv dfn-paneled idl-code" data-dfn-for="NavigatorOnLine" data-dfn-type="interface" data-export="" id="navigatoronline-navigatoronline">NavigatorOnLine</dfn> {
  <span class="kt">readonly</span> <span class="kt">attribute</span> <span class="kt">boolean</span> <a class="nv idl-code" data-link-type="attribute" data-readonly="" data-type="boolean" href="browsers.html#dom-navigatoronline-online" id="ref-for-dom-navigatoronline-online-1">onLine</a>;
};
</pre>
    <dl class="domintro">
     <dt><var>window</var> . <code>navigator</code> . <code>onLine</code>
     </dt><dd>
      <p>Returns false if the user agent is definitely offline (disconnected from the network).
    Returns true if the user agent might be online.</p>
      <p>The events <code>online</code> and <code>offline</code> are fired when the value of this attribute changes.</p>
    </dd></dl>
    <div class="impl">
     <p>The <dfn class="dfn-paneled idl-code" data-dfn-for="NavigatorOnLine" data-dfn-type="attribute" data-export="" data-lt="onLine|navigator.onLine" id="dom-navigatoronline-online"><code>navigator.onLine</code></dfn> attribute must return
  false if the user agent will not contact the network when the user follows links or when a script
  requests a remote page (or knows that such an attempt would fail), and must return true
  otherwise.</p>
     <p>When the value that would be returned by the <code>navigator.onLine</code> attribute of a <code>Window</code> or <code>WorkerGlobalScope</code> changes from true to false, the user agent must <a data-link-type="dfn" href="webappapis.html#queuing" id="ref-for-queuing-127">queue a
  task</a> to <a data-link-type="dfn" href="infrastructure.html#fire" id="ref-for-fire-151">fire a simple event</a> named <code>offline</code> at the <code>Window</code> or <code>WorkerGlobalScope</code> object.</p>
     <p>On the other hand, when the value that would be returned by the <code>navigator.onLine</code> attribute of a <code>Window</code> or <code>WorkerGlobalScope</code> changes from false to true, the user agent must <a data-link-type="dfn" href="webappapis.html#queuing" id="ref-for-queuing-128">queue a
  task</a> to <a data-link-type="dfn" href="infrastructure.html#fire" id="ref-for-fire-152">fire a simple event</a> named <code>online</code> at
  the <code>Window</code> or <code>WorkerGlobalScope</code> object.</p>
     <p>The <a data-link-type="dfn" href="webappapis.html#task-source" id="ref-for-task-source-24">task source</a> for these <a data-link-type="dfn" href="webappapis.html#tasks" id="ref-for-tasks-87">tasks</a> is the <a data-link-type="dfn" href="webappapis.html#networking-task-source" id="ref-for-networking-task-source-28">networking task source</a>.</p>
    </div>
    <p class="note" role="note"> This attribute is inherently unreliable. A computer can be connected to a network
  without having Internet access. </p>
    <div class="example" id="example-8f398a24">
     <a class="self-link" href="browsers.html#example-8f398a24"></a> In this example, an indicator is updated as the browser goes online and offline. 
<pre class="highlight"><span class="cp">&lt;!DOCTYPE HTML&gt;</span>
<span class="nt">&lt;html&gt;</span>
  <span class="nt">&lt;head&gt;</span>
    <span class="nt">&lt;title&gt;</span>Online status<span class="nt">&lt;/title&gt;</span>
    <span class="nt">&lt;script&gt;</span>
      <span class="kd">function</span> <span class="nx">updateIndicator</span><span class="p">()</span> <span class="p">{</span>
        <span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="s1">'indicator'</span><span class="p">).</span><span class="nx">textContent</span> <span class="o">=</span> <span class="nx">navigator</span><span class="p">.</span><span class="nx">onLine</span> <span class="o">?</span> <span class="s1">'online'</span> <span class="o">:</span> <span class="s1">'offline'</span><span class="p">;</span>
      <span class="p">}</span>
    <span class="nt">&lt;/script&gt;</span>
  <span class="nt">&lt;/head&gt;</span>
  <span class="nt">&lt;body</span> <span class="na">onload=</span><span class="s">"updateIndicator()"</span> <span class="na">ononline=</span><span class="s">"updateIndicator()"</span> <span class="na">onoffline=</span><span class="s">"updateIndicator()"</span><span class="nt">&gt;</span>
    <span class="nt">&lt;p&gt;</span>The network is: <span class="nt">&lt;span&gt;</span>(state unknown)<span class="nt">&lt;/span&gt;</span>
  <span class="nt">&lt;/body&gt;</span>
<span class="nt">&lt;/html&gt;</span>
</pre>
    </div>
   </section></main>
  
<script src="js/fixup.js"></script>
  

<p class="prev_next">← <a href="editing.html#editing"><span class="secno">5</span> <span class="content">User interaction</span></a> — <a href="index.html#contents">Table of contents</a> — <a href="webappapis.html#webappapis"><span class="secno">7</span> <span class="content">Web application APIs</span></a> →</p></body></html>
